Skip to content

fix: only the winning experiment is exposed for a shared variable key - #7

Merged
joalves merged 18 commits into
mainfrom
fix/shared-variable-key-winner
Nov 27, 2026
Merged

joalves merged 18 commits into
mainfrom
fix/shared-variable-key-winner

Conversation

@joalves

@joalves joalves commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix shared-variable-key resolution to match Java core-api Context.getVariableAssignment:

  • The candidates are the experiments where any variant defines the key, in ascending experiment-id order.
  • The winner is the first candidate the user is assigned to, overridden into or rule-assigned to. A user who is assigned but outside the traffic split still wins and gets the control value. A strict audience mismatch, or no unit for the experiment's unit type, does not qualify.
  • The winner is chosen before its selected variant is checked for the key. If that variant does not define the key (or an override points to a variant the experiment does not have), the caller default is returned. A later experiment's value is never used.
  • Only the winner is exposed, even when it returns the default. If there is no winner, nothing is exposed. peek_variable_value() exposes nothing. Null, false, 0 and empty values count as values; only a missing key returns the default.
  • Both read methods share one private resolver. The public API is unchanged.

What was wrong: variable_value() exposed every candidate it visited. That included experiments the user was not in and experiments that ended on the default. Both reads also fell through to a later experiment when the winner's arm lacked the key. This recorded users in experiments they never saw, and let the arm a user got decide which experiment counted them.

Who is affected: anyone with two or more running experiments that share a variable key. When only one experiment defines a key, variable_value() also stops exposing users who are not in it. treatment() is unchanged.

Docs: README has a new "Shared variable keys" note. The CHANGELOG has an Unreleased Fixed entry covering what was wrong, who is affected and the rule now applied. The notes already released are now under ## 1.0.0 (2026-11-16) (they were still under Unreleased).

Owner decision / Java parity

This PR applies the owner's final shared-key decision. Java reference: absmartly/java-sdk@9b2414bf40ee5b51b0f690d099b7c4e6ce7a5187, core-api Context.getVariableAssignment. The independent reviewer confirmed it matches line for line.

The C++ SDK has no holdouts, so none are added here, and the PR does not depend on any holdouts or switchbacks branch. Flag, not decided here: Java fires the applicable holdout exposures for every candidate it visits, while ordinary experiment exposure is winner-only. That looks inconsistent with a blanket "only the winner is exposed" rule.

Tests and evidence

  • Tests failed first: they were written and run before the fix. On the base, 7 of the 9 initial cases failed (12 assertions):

    • a strict-mismatch or missing-unit candidate queued 2 exposures instead of 1;
    • a winner whose arm lacked the key returned the later candidate's value;
    • with no candidate assigned, 2 exposures were queued instead of 0.
  • Guards already passing on the base: peek, lowest-id participant, and some override and rule paths. These are not claimed to fail before the fix.

  • Full suite: 161/161 pass in a Release build and in a strict C++17 Debug build (-Wall -Wextra -Wpedantic). The strict build has no warnings, and the package target builds.

  • Clang: Clang 22 passed all tests at the production-fix commit. Later commits changed only tests and docs.

  • Mutation checks, all caught by the tests:

    • exposing every visited candidate (the old behaviour);
    • falling through when the winner's arm lacks the key;
    • requiring a winner to be eligible, or to match the audience;
    • marking a losing candidate as exposed;
    • re-exposing a rule winner on every read;
    • not letting a custom assignment win (via variable_value() or peek);
    • letting a custom assignment alone make an unassigned candidate win.

    The final reviewer killed 20 of 20 mutants. A new test pins that a logger calling refresh() from inside the exposure event does not disturb the read. On main this is an ASan heap-use-after-free (src/context.cpp:304); head passes, including under ASan+UBSan.

cross-sdk-tests changes needed

Tested SDK SHA for the cross-sdk-tests#52 worker (run_vsuw6q537c6gwi3i): 6223db2177072660df3885bde618c52bea4d3580.

This PR makes no cross-sdk-tests changes and opens no per-SDK cross-sdk-tests PR. The consolidated PR should:

  • make the Java-recorded shared-variable-key scenarios required for cpp (the sharedVariableKeys capability);
  • retire or regenerate the older JS-rule scenarios 230-245 (branch feat/shared-variable-key-conformance-ready). They encode the superseded expose-every-candidate/fall-through rule, so they fail on this head by design.

Status for reviewers

  • Head: 6e54bb9. Jervasion APPROVED this exact head (round 4: no findings, no suggestions, no open threads). The final independent sdk-review on the same SHA is also APPROVE (no P1/P2/P3); the evidence is in a PR comment. CI is green.
  • Every Jervasion finding from rounds 1-3 is fixed, and every thread has a reply and is resolved.
  • Rule: the owner's final shared-key rule. Only the winner is exposed. A winner whose variant lacks the key returns the default, with no fall-through to a later experiment.
  • Coordination: feat(context): holdouts, matching javascript-sdk #5 (holdouts) and feat(context): switchback experiments, matching java-sdk #6 (switchbacks) rewrite variable_value() with the old JS rule. Whichever merges second has to re-apply this rule.
  • Release: the CHANGELOG entry stays under Fixed, as the owner asked. The version is still 1.0.0; the reviewer recommends 1.1.0 at tag time, and that is the owner's call.
  • Nothing is merged, tagged or published.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Shared variable keys now resolve using the first eligible experiment in ID order. If its assigned variant does not define the key, the caller’s default is returned without checking later experiments.
    • Variable reads expose only the selected assignment; peeks do not expose assignments.
    • Cached overrides created before an experiment was loaded are discarded when they do not match the loaded experiment.
  • Documentation
    • Added guidance on shared-key resolution, defaults and exposure behaviour.

lux worker and others added 7 commits November 23, 2026 23:17
Fails on main: an unassigned lower-id candidate (strict audience mismatch,
no unit) and a winner on an arm without the key were exposed too, and a
later candidate supplied the value when the winner's arm lacked the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
variable_value() exposed every candidate it visited and both reads fell
through to a later experiment when the winner's arm did not define the
key. The winner is now the first candidate by id the unit is assigned,
overridden or rule-assigned to; its variant supplies the value or the
caller default, and only it is exposed. Matches the Java SDK's
Context.getVariableAssignment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…didate still wins a shared key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xposed for treatment()

Also say in the README and CHANGELOG that a unit outside the traffic split
still wins with the control value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ttribute change and refresh

The v1.0.0 notes were still under Unreleased, so the shared-key entry read
as part of the released version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed winner

Also say in the CHANGELOG that a key defined by one experiment no longer
exposes a unit outside it, and how an out-of-range override now resolves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joalves

joalves commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on 6223db2: COMMENT (no P1/P2), 7 P1/P2 fixed across 6 reviewer passes

Earlier passes and what was fixed, all test gaps or docs, no production defect found:

  • b67d637: untested traffic-excluded and non-strict-mismatch winners -> tests added
  • 867c4aa: a loser silently marked exposed was untested -> test added
  • b14ad93: CHANGELOG filed into the released 1.0.0 notes -> released notes moved under a 1.0.0 heading
  • cd40dd9: rule winner re-exposure and custom winners untested; single-experiment exposure change undocumented -> tests and CHANGELOG
  • 5d15893: custom winner through peek untested -> test added
  • 6223db2: no P1/P2. The P3 (README wording) is addressed in a docs-only follow-up.

Final reviewer report:

.git/sdk-review/6223db2…md

COMMENT at 6223db2: the implementation matches Java's Context.getVariableAssignment and is well tested (15/15 mutants killed), the public API and ABI are unchanged, and the cached read path got faster. Before it merges, the owner needs to settle one conflict: the new rule contradicts the recorded shared-variable-key contract (contracts §6, owner decision 2026-11-06), the javascript-sdk reference and cross-sdk scenarios 230-245. Those scenarios pass 16/16 on main and fail 16/16 on head.

Compared the released v1.0.0 (GitHub release tarball; its headers are byte-identical to tag v1.0.0 = 9ea8669) → main/merge base 1c628e4 → head 6223db2. Parity checked against java-sdk main 9b2414b, javascript-sdk main 311cfca and cross-sdk-tests main e638655, plus branch feat/shared-variable-key-conformance(-ready) 788d43b (scenarios 230-245). Only this PR's delta counts as a finding.

Must fix

None at P1 or P2 against the brief given for this change.

Owner call (blocks merge until decided, not a code defect)

  1. Contract conflict: winner-only exposure, no fall-through (Java) vs expose every visited candidate and fall through (JS, contracts §6, cross-sdk 230-245).
    • Main and v1.0.0. Both walk the candidates in id order. Each candidate that has variables is exposed. The value comes from the first candidate that is assigned, overridden or rule-assigned and whose variant defines the key. This is javascript-sdk context.ts:1025-1058 (_resolveVariableValue) verbatim, and it is what references/contracts.md §6 records as the owner decision of 2026-11-06 (cross-sdk 119). past-findings records dotnet-sdk#8 round 2: "exposing only the value-supplying experiment causes sample-ratio mismatch on the other".
    • Head. Implements java-sdk Context.java:2050 (getVariableAssignment) exactly. Only the winner is exposed, and a winner whose variant lacks the key returns the default.
    • Measured. I ran a harness over the 16 cross-sdk Shared Variable Key scenarios (230-245, expected values recorded from @absmartly/javascript-sdk 1.13.4): main 16 pass / 0 fail, head 0 pass / 16 fail. Every failure is the new rule (the value is the default where JS falls through; the losing candidates are not exposed).
    • Customer impact. A 20-UID × 2-unit-config sweep over 5 experiments and 5 keys gave 54 of 400 value reads changed and 192 → 120 exposures. That matches what the CHANGELOG says: values move for users whose winning arm lacks the key, and exposure counts drop.
    • Release gate. cross-sdk sdk-branches.sh pins cpp-sdk to main, and that group is not on cross-sdk main yet. When it lands, cpp-sdk turns red unless the scenarios are regenerated from the Java rule. JS and Java already diverge here.
    • Please have the owner confirm that the Java rule supersedes contracts §6. Then update the cross-sdk group (230-245) and javascript-sdk before or together with this PR. Otherwise keep main's JS behaviour. The code itself needs no change if the Java rule is confirmed.

Tests needed (current implementation correct)

15 full-suite mutations: 15 killed, 0 survived (1 mutant first failed to compile; I fixed the patch and reran it). These include the old main rule (expose every visited candidate), fall-through on a missing key, payload-order indexing, descending-id walk, dropping assigned/overridden/rule_override one at a time, eligible-instead-of-assigned, peek queueing, a dropped or duplicated exposure, losing candidates marked exposed without being queued, a has_variables gate, and peek falling through. No survivors, so no test gaps.

Compatibility / parity / forward-compat evidence

  • Public API: the only header change is one new private non-virtual member (variable_assignment) and #include <utility>. No public member, struct field or virtual changed (git diff origin/main HEAD -- include: 0 virtual lines).
  • An external consumer probe built from the README API compiled and linked against v1.0.0, main and head.
  • The released v1.0.0 test suite run against head's library: 1474 assertions / 140 test cases, all passed. On their own trees: v1.0.0 140/140, main 141/141, head 155/155, all passed.
  • No-rule behaviour sweep (UIDs: ASCII, 0, -1, 9007199254740993, 1.5, padded, accented, CJK, emoji, email, digits, ×2 with/without user_id): v1.0.0 == main byte-for-byte. main → head differs only on shared or single-experiment keys, as documented: values for winners whose arm lacks the key, and no exposure for candidates the unit is not in. Keys whose single experiment assigns the unit (solo2) are identical.
  • Java parity: the winner condition (assigned || overridden || ruleOverride), id-sorted index, peek without exposure, and no variables gate (an override to an unknown variant wins and returns the default) all match Context.java:2050-2085 / :723-777. Holdout suppressedFallback does not apply (this SDK has no holdouts).
  • Every entry point: variable_value and peek_variable_value share one resolver. Tested via direct construction (create-with-data) and via refresh() with a data provider. The fetch path (SDK::create_context) has no shared-key test, but the resolver is the same code with no path-specific wiring, so this is not a finding.
  • Forward compat: the decoder and models are untouched by the diff, and the released suite passes on head. Not re-probed (NOT RUN, no decoder delta).

Performance

Warmed cached reads, 2,000,000 iterations, -O2, gcc 15.2, aarch64, my 5-experiment fixture (synthetic, not end-to-end): variable_value main ~131-133 ns/op → head ~83 ns/op; peek_variable_value the same. Head stops at the first assigned candidate. No regression. I did not measure allocations: the value is returned by json copy on both trees, unchanged.

P3 / notes

  • P3 docs: the README "Shared variable keys" paragraph (README.md:322) says only that variable_value() returns the default when the winner's variant lacks the key. peek_variable_value() does the same, and the CHANGELOG says so. Please write "variable_value() and peek_variable_value() return your default".
  • Note: the CHANGELOG calls main's fall-through a bug ("could also return a value from a later experiment"). That fall-through was the agreed JS contract. The wording should change if the owner keeps the decision framed as a contract change rather than a fix (see the owner call).

Version and release notes

  • The published version is 1.0.0 (tag v1.0.0, GitHub release 2026-11-16). project(... VERSION 1.0.0) is unchanged on head, and the entry sits under ## Unreleased with no version yet. Owner call: 1.0.1 vs 1.1.0. My recommendation is 1.1.0, because returned values and exposure counts move for existing users.
  • The released notes were moved under a new ## 1.0.0 (2026-11-16) heading. The body is byte-identical to v1.0.0's ## Unreleased section (diff empty), so nothing released was rewritten. The date matches the release.
  • The entry is under Fixed at the owner's explicit request. The skill's default would put customer-visible exposure and value changes under Changed, but the owner's instruction takes precedence. The entry does say who moves (anyone with shared keys, plus single-key experiments whose units are not in them).

Pre-existing on main (not this PR)

  • main 1c628e4 vs v1.0.0: only test-only friend struct ContextTestAccess, comment removals and added tests. No behaviour change (the sweep is byte-identical).

Verification limits / provenance: gcc 15.2 only (no clang installed). No CI run exists for this head: the branch is not pushed and there is no PR (git ls-remote returned nothing, gh run list was empty), so CI gates are NOT RUN on this head. Locally I ran the build, a strict-warnings syntax check of context.cpp, ctest 155/155 and cmake --target package. The cross-sdk scenarios were run through my own minimal C++ harness (value, exposure-id order, pending), not the official cpp-wrapper and orchestrator. Allocations were not measured. The JS expectations come from the scenario file, not from running JS.


sdk-review evidence: cpp-sdk (branch fix/shared-variable-key-winner, no PR)

  • Head: 6223db2177072660df3885bde618c52bea4d3580 (git rev-parse HEAD)
  • Mode: independent reviewer (read-only)
  • Previous pass / review: none found in .git/sdk-review/
  • Scratch: /tmp/sdkrev.FEQg (worktrees head/main/rel, removed after), /tmp/sdkrev-probe, /tmp/sdkrev-scripts

1. Trees

Tree Identifier How obtained Verified
Released cpp-sdk v1.0.0 GitHub release absmartly-cpp-sdk-1.0.0-Linux.tar.gz gh release download v1.0.0 -p '*.tar.gz' diff -r -x sdk_version.h <tarball include/absmartly> <tag v1.0.0 include/absmartly>: identical
Main / merge base 1c628e4 git merge-base origin/main HEAD
Head 6223db2 git rev-parse HEAD; 7 commits git log origin/main..HEAD
  • Version: CMakeLists project(absmartly-sdk VERSION 1.0.0); X-Agent is generated from the project version (cmake/sdk_version.h.in); the CHANGELOG entry is under ## Unreleased. No bump yet (owner call).
  • Released CHANGELOG section intact: diff <(git show v1.0.0:CHANGELOG.md | sed -n '/^## Unreleased/,$p'|tail -n +2) <(sed -n '/^## 1.0.0/,$p' CHANGELOG.md|tail -n +2) → empty.

2. Backwards compatibility

  • API diff: git diff origin/main...HEAD -- include → +1 private method variable_assignment, +#include <utility>; 0 public changes, 0 virtual changes.
  • Consumer probe (/tmp/sdkrev-probe/probe.cpp): g++ -std=c++17 ... libabsmartly-sdk.a → rel rc=0, main rc=0, head rc=0.
  • Released tests vs head lib: copied the v1.0.0 tests/ into a head copy and built → "All tests passed (1474 assertions in 140 test cases)". Own trees: rel 1474/140, main 1492/141, head 1593/155, all passed.
  • Behaviour sweep: 20 UIDs × {session only, +user_id} × keys {k, other, solo, solo2, missing}. rel vs main cmp → identical. main vs head: 54/400 value reads differ, exposures 192 → 120. All differences come from the new winner rule (checked by hand on the uid=a, 0, -1 rows).
  • Error/null/logging: no exception or event-name changes in the diff; check_ready(true) kept on both methods.
  • Public fields whose effect changed: none.
  • Entry points: variable_value / peek_variable_value share variable_assignment; tested through the ctor-with-data path and refresh() with a provider.

3. Parity

  • java-sdk 9b2414b Context.java:2050 getVariableAssignment, :723 getVariableValue, :766 peekVariableValue: read side by side. Same winner predicate, same id-sorted index (:2358 binarySearch by id), no variables gate, peek with no side effects.
  • javascript-sdk 311cfca context.ts:1025 _resolveVariableValue: exposes every candidate that has variables and falls through on a missing key. Differs from head (identical to main).
  • cross-sdk-tests: the Shared Variable Key group is not on main e638655 (only 202 there). Branch feat/shared-variable-key-conformance(-ready) 788d43b: 16 scenarios (230-245), run with /tmp/sdkrev-probe/xsdk.cpp → main 16 pass / 0 fail; head 0 pass / 16 fail (e.g. 236: got "default" want "nokey-62-B", exposures [61] want [61,62]). Policy counts: 16 eligible / 0 skips of 16 in that group.
  • Numeric edge table §2a: NOT RUN. The diff touches no numeric parsing or assignment code.

4. Tests and mutation

  • Full suite on head: 155/155 test cases, 1593 assertions, real 0.018s (gcc 15.2 Release); ctest 100% (155).
    | # | Mutant (src/context.cpp variable_assignment / variable_value / peek_variable_value / build_index) | Result |
    |---|---|---|
    | 1 | drop rule_override from winner predicate | killed (2 failed) |
    | 2 | drop overridden | killed (5) |
    | 3 | assigned && eligible instead of assigned | killed (1) |
    | 4 | require key in variant (fall through, old rule) | killed (3) (first attempt was a build failure from a bad patch; rerun) |
    | 5 | expose every visited candidate (old main rule) | killed (12) |
    | 6 | mark losing candidates exposed without queueing | killed (2) |
    | 7 | never set exposed (re-queue per read) | killed (2) |
    | 8 | drop winner exposure | killed (13) |
    | 9 | peek_variable_value queues exposure | killed (4) |
    | 10 | walk candidates by descending id | killed (8) |
    | 11 | winner requires has_variables | killed (1) |
    | 12 | index in payload order (no id sort) | killed (8) |
    | 13 | peek falls through on missing key | killed (1) |
    | 14 | first candidate always wins | killed (12) |
    | 15 | drop assigned (override/rule only) | killed (15) |
    Totals: 15 run / 15 killed / 0 survived. Scripts: /tmp/sdkrev-scripts/mut.py, mut2.py.
    Standard-set mutants on rules/app_version/decoder/system attributes: not applicable (this diff does not touch that code).
  • Fix-commit audit (7 commits since main; no previous review): the only new state is the private variable_assignment. No new flags, stamps, caches or wiring. exposed is still set only next to queue_exposure (variable_value and treatment). Commits after b67d637 are tests and CHANGELOG only (git diff --stat).

5. Performance

Path main head probe counter test?
warmed variable_value 130.8-133.5 ns/op 83.3-83.6 ns/op 2e6 iters, -O2, gcc 15.2 aarch64, 3 runs each n/a, no cache added
warmed peek_variable_value 130.6-133.4 83.2-83.8 same n/a
Allocations NOT RUN (json returned by copy on both trees).

6. Forward compatibility

NOT RUN: the diff does not touch models.h or decoding; the released test suite passes on head.

7. Build / CI

  • cmake -S head -B b-head -DCMAKE_BUILD_TYPE=Release && cmake --build → rc=0, 0 warnings in the build log.
  • g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror -fsyntax-only src/context.cpp → ok.
  • cmake --build b-head --target package → absmartly-cpp-sdk-1.0.0-Linux.zip generated.
  • Floors: cxx_std_17 and CMake 3.16 unchanged.
  • clang: NOT RUN (not installed).
  • CI on this head: NOT RUN / none. The branch is not on origin (git ls-remote origin fix/shared-variable-key-winner empty) and there is no PR or run.
  • Pins: no fixture or submodule changes.

8. Docs / CHANGELOG

  • Section: ## Unreleased → ### Fixed (the owner asked for Fixed); released notes refiled under ## 1.0.0 (2026-11-16) byte-identically.
  • Migration notes vs the published API: no API change. The behaviour changes (values and exposures) are described, including the single-experiment case.
  • README.md:322 claims checked against tests: lowest id, override and rule winners; traffic-excluded gets control and an exposure; default with no exposure when not in any candidate. All true at head. It does not mention that peek_variable_value also returns the default when the key is missing (P3).
  • Stale strings: grep 1.0.0 README.md → only a semver example. No old agent strings in the diff.

Findings

Sev Title Evidence Fixed in
Owner call Java winner rule contradicts contracts §6 / JS / cross-sdk 230-245 §3 harness 16/16 → 0/16; §2 sweep 54/400 values, 192→120 exposures —
Owner call Version 1.0.1 vs 1.1.0 (no bump yet) §1 —
P3 README says only variable_value returns default for a keyless winner §8 —

Verification limits

  • No CI on this head (not pushed). No clang. Cross-sdk run through my own harness, not the official wrapper. JS was not executed: expectations come from the scenario file (recorded from JS 1.13.4). Allocations not measured. Forward-compat and numeric edge table not run (no delta).

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds a helper that selects the first qualifying experiment in ID order for a shared variable key. variable_value() reads from and exposes that assignment; peek_variable_value() reads from it without exposure. If no candidate qualifies, or the selected variant lacks the key, the caller’s default is returned. Refresh checks cached overrides when their experiment becomes available. Tests cover assignment, exposure, overrides, rules, falsy values, attribute changes, and refreshes. The README and changelog document the behaviour.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • absmartly/cpp-sdk#1: Adds context and override handling that shares the refresh and exposure paths changed here.
  • absmartly/cpp-sdk#3: Adds assignment rules that can qualify a candidate for shared-key selection.
  • absmartly/cpp-sdk#5: Adds fallback behaviour and holdout-based assignment suppression on the variable read path changed here.

Suggested reviewers: marcio-absmartly, jervasion-absmartly

Merge Risk: Minimal · up to 6e54b

Shared variable keys now expose only the winning experiment and return the caller's default instead of falling through to later experiments. This matches the reference Java behavior, and the public API is unchanged. Tests and CI pass, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main behaviour change: only the winning experiment is exposed when a shared variable key is defined by several experiments. The changeset matches this. The README, CHANGELOG, cont…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title states the main behaviour change: only the winning experiment is exposed when a shared variable key is defined by several experiments. The changeset matches this. The README, CHANGELOG, context.cpp and new tests all cover winner-only exposure for shared keys. The title is short, specific and free of noise, so a teammate scanning history can identify the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the keys in line,
The lowest qualifying ID will shine.
One winner leaves an exposure trace,
A peek reads on without that pace.
If no key is found, defaults appear,
Then tests and notes make the rules clear.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 237fef33-4dad-428e-9e58-8222c29cc638
Commits

Reviewing files that changed from the base of the PR and between 8e7d29c and 6e54bb9.

Files selected for processing: 3

  • CHANGELOG.md
  • src/context.cpp
  • tests/shared_variable_key_test.cpp
Files skipped from review as they are similar to previous changes: 1

  • CHANGELOG.md

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

…er without the key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joalves

joalves commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

P3-only follow-up on top of the gated 6223db2: f07687a changes only README.md, saying that peek_variable_value() also returns the default when the winner's variant lacks the key (the final reviewer's P3). No production code changed.

lux worker and others added 3 commits November 24, 2026 15:37
…le is replaced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…assigned shared-key candidate win

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ure does not disturb the read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joalves

joalves commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on c45201b: APPROVE (no P1/P2), 1 P1/P2 fixed across 2 reviewer passes

  • Pass 1 on abc764c (README/CHANGELOG wording from the previous review's notes): REQUEST_CHANGES with one P2 test gap. A mutant that let a custom assignment alone make an unassigned candidate win survived. It is fixed in c45201b with a test, and I confirmed locally that the test kills the mutant. Pass 1's P3, moving the CHANGELOG entry from Fixed to Changed, was not applied: the owner asked for this entry to be under Fixed, so it stays there.
  • Pass 2 on c45201b: APPROVE. 20/20 mutants killed. 22/22 eligible shared-variable-key scenarios (cross-sdk-tests#52) pass on head; main fails 9. Public API and ABI are unchanged.

Final reviewer report:

.git/sdk-review/c45201b….md

APPROVE at c45201b: the shared-variable-key resolver implements the owner's Java rule exactly (first assigned/overridden/rule-assigned candidate by ascending id wins, only it is exposed, no fall-through, peek exposes nothing). The public API, ABI layout and treatment() behaviour are unchanged. 20/20 mutants were killed, and the previous review's only P2 (custom-assignment survivor) is fixed. What remains are three P3 items and two owner/release notes. One release gate: CI must go green on c45201b after the push, because it has only run on f07687a.

Compared GitHub release v1.0.0 (tag 9ea8669; cpp-sdk has no package registry) → merge base / origin/main 1c628e4 → head c45201b. v1.0.0..main has 4 commits (tests, comments, a test-only friend; 0 lines in src/). Parity was checked against java-sdk 9b2414bf core-api Context.getVariableAssignment and cross-sdk-tests#52 head 2d8d4e5 (scenarios 340-368, recorded from Java). The JS rule (expose every candidate, fall through) and references/contracts.md §6 are superseded by the owner, so divergence from them is not a finding. Only this PR's delta is a finding.

Must fix

None. No P1/P2 found.

Tests needed (current implementation correct)

20 full-suite mutations: 20 killed, 0 survived. That is 17 on the resolver and read APIs, plus 3 extra ones aimed at the fix commits. Every mutant was run against the full 156-case suite.

  • Fix-commit audit (abc764c..c45201b, 1 commit, test only): it adds the test "a custom assignment alone does not make an unassigned candidate win". That test alone kills M15 (|| cassignments_.count(name) in the winner gate), which was the survivor of the abc764c review. It adds no new state, flags, caches or public names.
  • Failing-first check: head's shared_variable_key_test.cpp run against main's library (main source with head's test file) gives 15 cases, 11 failed / 17 failed assertions. The tests can fail on base.

Compatibility / parity / forward-compat evidence

  • Public surface. The released installed headers (v1.0.0 tar.gz) are byte-identical to the tag's include/ sources (cmp over 23 headers; sdk_version.h is generated). Head vs release context.h: #include <utility>, a private variable_assignment(), and main's test-only friend. sizeof(Context)=736, sizeof(Assignment)=184 and a customer struct embedding Assignment+Exposure (280) are identical on rel/main/head. nm -C diff of Context:: text symbols, main → head: +1 private variable_assignment, 0 removed.

  • Consumer probe. Built with the released package headers and linked against head's library, it gives byte-identical output to the head-header build. This covers public models, a custom ContextEventLogger subclass, and both read APIs.

  • Released and main suites on head's library. v1.0.0 tests 140 cases / 1474 assertions pass, and main tests 141 / 1492 pass. Head's own suite: 156 / 1597.

  • Behaviour sweep. 13 UIDs (ASCII, padded, café, CJK, emoji, "0", -1, 2^53+1 string, 1.23e17 int, 1.5, 42, hex), 6 experiments, 5 keys, 3 modes. treatment() mode output is byte-identical main → head on 13/13. Every difference in variable_value/peek mode falls into one of the two CHANGELOG-documented classes:

    • (a) unassigned single-key experiment e30 (missing unit) is no longer exposed: 13/13 UIDs;
    • (b) the winner e5 lacks key m in its control arm, so it returns the default instead of e6's value, and e6 is no longer exposed: 4/13 UIDs.

    Every surviving exposure is byte-identical (exposedAt excluded). The v1.0.0 source build's output == main's output.

  • cross-sdk-tests#52 2d8d4e5, sharedVariableKeys group. A direct C++ replay (no wrapper; results plus exposure-event subset match, step by step) over 29 scenarios gives 22 eligible / 7 skipped. The skips need holdouts (357, 358, 366, 367, 368) or switchback (359, 360), which cpp-sdk main lacks. Head passes 22/22. main passes 13/22, failing 340, 341, 347, 348, 349, 351, 356, 361, 362: exactly the list in expected-capabilities.json cpp sharedVariableKeys.

  • Java parity (source read). The C++ loop assigned || overridden || rule_override → return matches Java L2064. The value lookup (containsKey → value, else default) matches L728-735 and L769-777. The Java index sorts by id via binarySearch, and C++ build_index does the same with lower_bound. Holdout firing on losing candidates (Java L2058-2062) has no C++ counterpart because the SDK has no holdouts. The owner accepts that.

  • Entry points. Both read APIs go through the one private variable_assignment(), and there are mutants per API: M12 (peek exposes) and M17 (peek falls through) were killed. Both creation paths (with-data, future/fetch) end in build_index(), which is unchanged.

  • Null/exception contract. check_ready(true) is still first in both APIs. Missing key → default. JSON null/false/0/""/[]/{} are values (M16 killed).

  • Forward compatibility. A payload with unknown root/experiment/variant/application keys, holdoutIds, holdouts, switchbackClusters:null, applications:null, a missing variant config, config:"{bad", config:"[1]", assignmentRules:"not json" and "{}", and audience:"" gives an identical result on main and head (ready, shared key served, 1 exposure). The decoder is untouched by this PR.

  • Re-entrancy (bonus). A logger that calls refresh() + set_unit() from inside the exposure event, under ASan+UBSan, gives:

    • main: heap-use-after-free at context.cpp:304. The old loop kept iterating index_variables_ after queue_exposure. This is pre-existing in v1.0.0.
    • head: clean ("b1" "c1" pending=2). The resolver no longer touches the index after the exposure.

Performance

Warmed variable_value/peek_variable_value, 2,000,000 calls per row after 1,000 warm-up calls, -O2, g++ 15.2, aarch64, in-process static lib, 3 runs. The figures are synthetic steady-state reads, not end-to-end:

Row main ns/op head ns/op allocs/op main → head
shared key (2 candidates), value 70.7-72.4 68.3-69.7 1 → 1
shared key, peek 70.7-72.8 69.8-70.9 1 → 1
single-candidate key, value 78.2-80.9 75.1-76.8 1 → 1
single-candidate key, peek 77.7-80.4 75.7-77.5 1 → 1

The 1 alloc/op is the returned json copy and is unchanged. The PR adds no cache or memo, so no counter test is needed.

P3 / notes

  • P3: the head has not been pushed and CI has not run on it. The PR head is f07687a (CI runs 45377197669 push and 45377207804 pull_request, both green). c45201b adds +18/-2 on top: one test, plus CHANGELOG and README text. I ran the CI steps locally on c45201b and all passed:

    • Release configure/build;
    • ctest 156/156;
    • package (tar.gz and zip);
    • find_package consumer on both archives (prints absmartly-cpp-sdk/1.0.0);
    • add_subdirectory consumer (install tree is only ./bin/app, its CPack config is kept).

    A strict C++17 Debug -Wall -Wextra -Wpedantic -Werror + ASan/UBSan build had 0 diagnostics and 156/156 passed. Please push and confirm CI is green on c45201b before requesting a human.

  • P3: the PR description is stale. It says "Head: f07687a", "155/155", and that the gate passed on 6223db2. Please update it to c45201b, 156 cases / 1597 assertions, and this report, after the push.

  • P3: no test for re-entrancy during the exposure (production is correct). Head fixed a pre-existing use-after-free (above) as a side effect, but nothing pins it. A test whose ContextEventLogger calls refresh(other_data) on the first exposure event during variable_value() would protect it from a future rewrite that walks the candidate list after exposing. That rewrite is exactly what the feat/holdouts/feat/switchbacks branches do; see the next note.

  • Note (cross-PR merge risk, not this PR's defect). Open cpp-sdk#5 (feat/holdouts) and feat(context): switchback experiments, matching java-sdk #6 (feat/switchbacks, pinned by cross-sdk-tests#52 sdk-branches.sh at 52125e0) rewrite variable_value() with the JS rule. They keep a suppressed fallback and capture "remaining" candidates after the first exposure. Whichever merges second will conflict here and must re-apply the Java winner rule, adding winner-only holdout firing if the owner wants it. Please note the merge order in the PRs.

  • Note (cross-repo follow-up). In cross-sdk-tests#52, orchestrator/expected-capabilities.json still lists cpp sharedVariableKeys as unsupported (L641) for exactly the 9 scenarios head now passes. Flip it to required after merge.

  • Note. The skill's references/contracts.md §6 still describes the superseded JS rule (expose every candidate, fall through), and I did not apply it here. The contract text should be updated.

Version and release notes

  • The CMake version is still 1.0.0 (the X-Agent comes from it via sdk_version.h), with the new entry under ## Unreleased. The released notes moved under ## 1.0.0 (2026-11-16), and that section is byte-identical to the v1.0.0 tag's ## Unreleased body (diff empty), so the released notes are intact.
  • Owner decision (applied, not a finding): the entry is under ### Fixed as the owner asked. My default rubric would put a change to customer-visible exposure counts and served values under Changed. The entry already says who moves: anyone with ≥2 experiments sharing a key, single-key experiments losing exposures for non-participants, and out-of-range overrides.
  • Owner call: is the next tag 1.0.1 or 1.1.0? I recommend 1.1.0, because served values and exposure counts move for some 1.0.0 users.
  • Stale-strings grep: there are no "fall through" / "every candidate" claims left outside the CHANGELOG's own "replaces the earlier rule" sentence. The README "Shared variable keys" paragraph matches the measured behaviour, including peek returning the default.

Pre-existing on main (not this PR)

  • A logger-driven refresh() during variable_value()'s exposure caused a heap-use-after-free in the old candidate loop (ASan, context.cpp:304 on main; the code is identical in v1.0.0 since src/ is unchanged). Head removes it. If 1.0.x gets a patch release, track it separately.

Verification limits / provenance:

  • Everything ran on Linux aarch64 with g++ 15.2 and CMake. No clang or MSVC C++ compiler was available, and the PR body reports Clang 22 at b67d637.
  • The released libabsmartly-sdk.a is x86-64 (readelf: Machine X86-64), so it cannot be linked here. The release baseline is the v1.0.0 tag built from source, and its installed headers were verified byte-identical to the tag.
  • The cross-sdk numbers come from my direct replay harness (results plus exposure-event subset), not the orchestrator/Docker lane.
  • CI on the exact head c45201b is NOT RUN (not pushed). That is the release gate above.
  • Scratch worktrees were in /tmp/sdkrev.OFaL and have been removed. The PR working tree was not modified (git status clean).

sdk-review evidence: cpp-sdk#7

  • Head: c45201b952b870d95175305f7f7c6788f2283b04 (local HEAD; gh pr view 7 --json headRefOid = f07687a, so c45201b is not pushed; f07687a..c45201b = abc764c (docs) + c45201b (test))
  • Mode: independent reviewer
  • Previous review: .git/sdk-review/abc764c04ab721664b793d05bd441d0928444317.md (REQUEST_CHANGES: 1 P2 test gap (custom-assignment survivor) + P3 CHANGELOG placement). Commits since: 1 (c45201b).
  • Run date: 2026-11-24

1. Trees

Tree Identifier How obtained Verified
Released v1.0.0 GitHub release (2026-11-16), tag commit 9ea8669 gh release list/view/download -R absmartly/cpp-sdk tar.gz headers cmp == tag include/ (only sdk_version.h generated); lib is x86-64 (readelf) so it was rebuilt from the tag
Main / merge base 1c628e4 git merge-base origin/main HEAD git diff v1.0.0 origin/main --stat: context.h (+4/-2, friend/comments), assignment_rules_test.cpp only
Head c45201b git rev-parse HEAD

Version source / X-Agent / CHANGELOG heading: CMake project(... VERSION 1.0.0) → SDK_AGENT (client.cpp:52) → the package consumer prints absmartly-cpp-sdk/1.0.0. The CHANGELOG new entry is under ## Unreleased. The released section is byte-identical to the tag (diff empty).

2. Backwards compatibility

  • API diff: diff rel/include/absmartly/context.h head/... gives +<utility>, +private variable_assignment, +test friend (main-era), and -2 comments. nm -C main→head Context:: T symbols: +1 private, 0 removed.
  • sizeof probe (probe/sz.cpp, rel/main/head headers): 736 / 184 / 280 on all three.
  • Consumer probe probe/probe.cpp built with the release-package headers + head lib: output cmp-identical to the head-header build. With the v1.0.0 source lib: identical to main.
  • Released tests vs head lib: v1.0.0 tests 140 cases / 1474 assertions pass; main tests 141 / 1492 pass; head 156 / 1597 pass. No extra failures.
  • Behaviour sweep: 13 UIDs × 6 experiments × 5 keys × modes {all, peek, treat}. treat: 0/13 lines differ. all: 13/13 differ, classified by cmp.py: e30 exposure removed (13), e6 removed + m → default (4). All kept exposures are identical. peek: 4/13 differ (m → default only).
  • Error/null contract: check_ready(true) first in both APIs (source); not-ready/finalized tests pass in the suite.
  • Public fields/hooks whose effect changed: none (no public field read/write changed).
  • Entry points: both read APIs share the resolver (M12, M17 killed); creation paths are untouched.

3. Parity

  • Java 9b2414bf Context.java fetched via gh api; getVariableAssignment L2050-2080, getVariableValue L723-736, peekVariableValue L766-778, index sort L2358-2374. These match the C++ semantics line for line (holdouts are N/A).
  • cross-sdk-tests#52 2d8d4e5 test_scenarios_complete.json, requires contains sharedVariableKeys: 29 scenarios; 22 eligible / 7 skips (357, 358, 366, 367, 368 holdouts; 359, 360 switchback). replay/replay.cpp: head pass=22 fail=0; main pass=13 fail=9 (340, 341, 347, 348, 349, 351, 356, 361, 362).
  • Numeric edge table §2a: NOT RUN, because this diff touches no rule or numeric parsing (rule paths are unchanged; git diff --stat src = context.cpp resolver only).
  • JS vectors: NOT RUN by design, because the owner superseded the JS rule for this contract.

4. Tests and mutation

  • Full suite on head (Release, g++ 15.2): 156 cases / 1597 assertions pass, 0.016 s. Strict C++17 Debug -Wall -Wextra -Wpedantic -Werror -fsanitize=address,undefined: 0 diagnostics, 156/156.
  • Failing-first: head test file on main source gives 15 cases, 11 failed; 66 assertions, 17 failed.
# Mutant (src/context.cpp) Killed by Result
M1 expose every visited candidate (old rule) 13 cases incl. svk:111,185,215 killed
M2 mark losing candidate exposed without queuing "losing candidate still exposed by its own treatment()" killed
M3 fall through when winner lacks key svk:228, 337 killed
M4 drop assigned from gate 16 cases killed
M5 drop overridden context "variables", svk overrides killed
M6 drop rule_override svk rules, rules "assign" killed
M7 require eligible "assigned candidate wins even when not eligible" killed
M8 require audience match same killed
M9 first visited candidate always wins 13 cases killed
M10 re-expose on every read svk:137 + 2 killed
M11 variable_value never exposes 14 cases killed
M12 peek exposes the winner context peek variable value, svk:185, 228 killed
M13 walk highest id first 8 cases killed
M14 index in name order, not id 8 cases killed
M15 custom assignment alone makes a candidate win "custom assignment alone does not make an unassigned candidate win" (c45201b) killed
M16 JSON null treated as missing "falsy values are values" killed
M17 peek falls through when winner lacks key svk:228 killed
M18 expose the winner only if its arm has the key svk:228, 337 killed
M19 gate also requires has_variables (out-of-range override) svk overrides "unknown variant" killed
M20 walk continues past the winner (last qualifying wins) 19 cases killed

Totals: 20 run / 20 killed / 0 survived. After each mutant the source was restored, rebuilt and the suite re-run: 156/156. Worktree git status clean.

  • Fix-commit audit:
Commit New state Must be set/cleared/read Entry points skipping it Mutant
c45201b none (test only) n/a n/a M15 now killed
abc764c (docs, since the prior review's head) none n/a n/a n/a

5. Performance

Path main head probe size / runtime counter test exists?
shared key value 70.7-72.4 ns, 1 alloc 68.3-69.7 ns, 1 alloc 2M calls ×3, -O2, aarch64 g++15 n/a (no new cache)
shared key peek 70.7-72.8 69.8-70.9 same n/a
single key value 78.2-80.9 75.1-76.8 same n/a
single key peek 77.7-80.4 75.7-77.5 same n/a

6. Forward compatibility

  • probe/fc.cpp: unknown root/experiment/variant/application keys, holdoutIds/holdouts/switchbackClusters:null, applications:null, missing config, config set to "{bad" / "[1]" / null, assignmentRules set to "not json" / "{}" / omitted, audience:"", payload order not by id. main and head both give ready=1 k="b0" pk="b0" pending=1 t_c=1. The decoder is unchanged by the PR.
  • Re-entrancy probe/reent.cpp (ASan+UBSan): main heap-use-after-free at context.cpp:304; head clean.

7. Build / CI

  • Local CI steps on c45201b, all passing: configure/build/ctest 156/156, cmake --build build --target package → tar.gz and zip, package_consumer on both archives → absmartly-cpp-sdk/1.0.0, subdirectory_consumer → install tree ./bin/app, CPackConfig keeps embedding-app/TGZ.
  • Floors: CMake 3.16, C++17 unchanged (CMakeLists.txt/.github diff vs main: 0 lines).
  • Strict/newest: g++ 15.2 -Werror -Wall -Wextra -Wpedantic with ASan/UBSan, 0 diagnostics. Clang NOT RUN (not installed).
  • CI on exact head: NOT RUN, because c45201b is not pushed. The latest CI is on f07687a: runs 45377197669 (push) and 45377207804 (pull_request), both success. Release gate.
  • Pins: this PR adds no pins. cross-sdk-tests#52 pins cpp-sdk to feat/switchbacks 52125e0 (open PR feat(context): switchback experiments, matching java-sdk #6, not this branch). Noted.

8. Docs / CHANGELOG

  • Section/version: ## Unreleased → ### Fixed (owner-directed); released 1.0.0 notes are intact (diff vs tag empty).
  • Migration notes vs published 1.0.0: no API break. The behaviour changes are documented with who moves (multi-key users; single-key non-participants losing exposures; out-of-range overrides).
  • Added vs Changed: owner chose Fixed. Recorded as an owner decision, not a finding.
  • Stale strings: git grep -i "fall.\?through\|every candidate" outside CHANGELOG finds only murmur3 [[fallthrough]]. The README paragraph matches the measured behaviour. The PR body is stale (f07687a, 155/155).

Findings

Sev Title Evidence line above Fixed in
P3 head not pushed; CI not run on c45201b §7 open (push + green CI)
P3 PR description cites f07687a / 155 tests §8 open
P3 no re-entrancy test pinning the UAF fix §6 open (optional)
note merge conflict/rule regression risk with cpp-sdk#5/#6 §7 pins cross-PR
note cross-sdk-tests#52 expected-capabilities still marks cpp sharedVariableKeys unsupported §3 cross-repo
owner Fixed vs Changed; 1.0.1 vs 1.1.0 §8 owner

Verification limits

  • Clang/MSVC NOT RUN (no compiler available); released x86-64 lib not linkable on aarch64 (rebuilt from tag instead); CI on exact head NOT RUN (unpushed); JS vectors and numeric edge table NOT RUN (out of scope: superseded rule / no numeric code touched); cross-sdk numbers come from a direct replay, not the orchestrator lane.

@joalves

joalves commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

P3-only follow-up on top of the gated c45201b: 3b1915e adds one test section and changes no production code. It is the final reviewer's optional P3: a ContextEventLogger calls refresh() from inside the shared-key read's exposure event. Main hits an ASan heap-use-after-free at src/context.cpp:304 (I verified this by running the new section against origin/main under ASan). Head passes, in both Release and ASan+UBSan builds (156/156).

The reviewer's other two P3s (CI on the new head; the PR body is stale) are handled by this push and the updated Status section.

@jervasion-absmartly

jervasion-absmartly commented Nov 26, 2026 •

Copy link
Copy Markdown

Review submitted

The automated review has been submitted. See the review for the verdict and any findings.

Head: 6e54bb98eff6 | Updated: 2026-11-27 13:38 UTC

@jervasion-absmartly

Copy link
Copy Markdown

Question Q1 — Simplify the shared-key refresh fixture

Is the provider-backed refresh in the winner-removal test meant to pin a separate contract, or can the test call refresh(data_of({high_exp()})) directly and drop the one-use provider fixture?

Context: tests/shared_variable_key_test.cpp:93–105,388–395; FixedDataProvider has one use. The baseline Context refresh/cache-invalidation tests already exercise provider-backed refresh, and refresh() forwards fetched data to refresh(const ContextData&) in src/context.cpp:568–580. The new logger test also uses the direct overload. I found no provider-specific requirement in the PR description or review discussion.

Why I'm asking: If the test only needs to cover winner removal, the direct overload exercises the same index rebuild and avoids a test-only provider class and promise.

Suggested answers (free text is always welcome):

  • The test only needs to pin winner removal; direct refresh is enough.
  • Keep provider-backed refresh to pin the SDK fetch-to-resolver path.

@joalves, please include Q1 or this comment's link in your reply. Free-text answers are always welcome. I'll keep checking the rest of the change in the meantime.

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested

The new resolver implements the intended winner-only rule for ordinary reads. I found two cases where the SDK can return the wrong value or record an exposure that does not match it, plus one regression test that still passes when the behavior it names is broken.

Next step: Make the value and exposure agree across refresh and logger callbacks, and strengthen the refresh regression test.

Must fix

  1. Bind overrides cached before an experiment arrives — a prior peek() can make a newly loaded winner return the default and publish an exposure with ID 0. src/context.cpp:311
  2. Keep the returned value aligned with the recorded exposure — a synchronous logger can change the cached arm before the read returns. src/context.cpp:332
  3. Make the callback-refresh test distinguish the in-flight read from the next lookup — the current test passes even if the resolver looks up the key again after the callback. tests/shared_variable_key_test.cpp:398

Suggestions (optional)

  • One possible test-fixture simplification and four redundant comment blocks are noted in the review details.

Unanswered author questions

What I checked

  • ✅ The local Release build and all 156 CTest cases passed, including 15 shared-key cases.
  • ✅ Both exact-head GitHub CI runs passed build, test, package, and package-consumer checks.
  • ✅ The focused probe confirmed the intended ordinary winner selection and reproduced both incorrect results above. A separate mutation run confirmed the refresh test gap.
Review details

Head: 3b1915e5f30416a146cba17d469a4738394a77c3
Base, merge base and responsibility baseline: 1c628e4dee98c24ec16a697bb382363d89bad723
Round: 1 (initial).

The owner decision recorded in the PR replaces the previously shipped JS-style fall-through with the Java selection rule. I checked the cited Java revision (9b2414bf40ee5b51b0f690d099b7c4e6ce7a5187): ordinary winner selection and missing-key fallback match; Java-only holdouts are out of scope. Both public getters are affected, as are the exposure records handed to the publisher. treatment() and public signatures are unchanged. The changelog describes the change for shared and single-experiment keys. The separate conformance PR, absmartly/cross-sdk-tests#52, is open; I did not rerun its cross-SDK suite or treat the older JS scenarios as an exact-head gate.

Commands and results: git diff --check 1c628e4d HEAD passed; cmake -S . -B /workspace/cpp7-build -DCMAKE_BUILD_TYPE=Release -DABSMARTLY_BUILD_TESTS=ON, cmake --build /workspace/cpp7-build --parallel 4, ctest --test-dir /workspace/cpp7-build --output-on-failure and cmake --build /workspace/cpp7-build --target package passed (156/156; TGZ and ZIP). g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror -fsyntax-only passed on src/context.cpp with the configured JSON headers. The public-API probe ran against the exact-head library and then with the merge-base context.cpp object; the production-only mutation likewise replaced only that object and ran the unchanged Catch2 suite (1601 assertions, 156 cases). Actions runs 45439925244 and 45439907790 both reported Build & test successful for the exact SHA.

Passes (non-blocking): run: core runtime/API/data (resolver and exposure path); dedicated error-handling specialist completed (default/failure paths, callback and publisher behavior); tests/CI/packaging (new registered test file and public behavior); deployment/operations/observability (changed exposure emission and collector payload); cross-cutting simplicity; comment hygiene; diff composition. Not run: shared-component UI (no frontend files); behaviour-bearing data/policy (no runtime data, schema or policy files; test fixtures are embedded in the compiled C++ tests and were reviewed there).

Comment hygiene (non-blocking): 26 comment / 375 code lines, ratio ~1:14.4, 4 blocks flagged.
threshold T=5; restatements counted: no (10 × C < E)

  • include/absmartly/context.h:136–137 — restates the returned winner/pair and null case.
  • tests/shared_variable_key_test.cpp:47 — restates that the adjacent fixtures define the key only in variant 1.
  • tests/shared_variable_key_test.cpp:56 — restates the strict-mismatch fixture.
  • tests/shared_variable_key_test.cpp:62 — restates the missing-unit fixture.

Diff composition (non-blocking): every file is required for the change; none flagged. The pinned helper enumerated 20 content writes across the 11 PR commits; checked their paths and contents, including replaced versions. README endpoint and key examples are placeholders.

Simplifications (non-blocking): 1 candidate.

  • If the winner-removal test is not meant to cover provider-backed fetching, use the direct refresh(data) overload and remove the one-use FixedDataProvider (roughly 10 fewer code lines; equivalence not established while Q1 is open).

Run a simplification pass locally before pushing: these candidates cost less to address now than as a further review round.

Comment thread src/context.cpp Resolved
Comment thread src/context.cpp Resolved
Comment thread tests/shared_variable_key_test.cpp Resolved
…shes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested

All three blockers from the previous review still reproduce on the unchanged head. The Java-style winner rule is not in dispute.

Next step: Address the three existing threads; no new blockers were found.

Must fix

  1. Bind an override cached before its experiment arrives — after refresh, the read must use the loaded experiment's value and exposure metadata, not the placeholder's default and ID 0.
  2. Keep the returned value and queued exposure on the same arm — an override change inside the exposure logger can affect later reads, but must not change the value returned by the in-flight read.
  3. Make the logger-refresh test distinguish the original read from a fresh lookup — the test must fail if the read reselects its winner after the callback.

Suggestions (optional)

  • One possible fixture simplification and four redundant comment blocks are listed below.

Unanswered author questions

What I checked

  • ✅ Local Release build, all 156 CTest cases, and both package archives passed.
  • ✅ Both exact-head GitHub Actions runs passed, including the package-consumer checks.
  • ✅ An independent recheck reproduced both runtime defects and confirmed that the callback-refresh test still passes with a re-lookup mutation that changes the in-flight result. Failed refresh and publish/retry behavior also worked as expected.
Review details

Head: 3b1915e5f30416a146cba17d469a4738394a77c3
Base, merge base and responsibility baseline: 1c628e4dee98c24ec16a697bb382363d89bad723
Round: 2 (review_requested). No source changes since round 1 and no reply addressing the three findings. Existing inline threads carry the reproduction details; no duplicate inline comments.

The PR deliberately replaces JS-style fall-through with the Java rule for the public variable getters and ordinary exposure records. C++ holdouts and the separate cross-SDK conformance PR are out of this change's scope. The failure-path specialist confirmed that refresh-provider and publish errors retain the expected recovery behavior; the two reproduced defects are in the public return value and the SDK's queued exposure record, not an assumption about collector acceptance. The mutation finding is about the in-flight result named by the test, not the narrower invalidated-iterator guard the test also provides.

Validation: git diff --check 1c628e4d HEAD; cmake -S . -B /workspace/cpp7-r2-build -DCMAKE_BUILD_TYPE=Release -DABSMARTLY_BUILD_TESTS=ON; cmake --build /workspace/cpp7-r2-build --parallel 3; ctest --test-dir /workspace/cpp7-r2-build --output-on-failure --quiet; absmartly_tests '[shared-variable-key]' (109 assertions / 15 cases); cmake --build /workspace/cpp7-r2-build --target package; and strict C++17 syntax checking of src/context.cpp (-Wall -Wextra -Wpedantic -Werror). Actions runs 45439925244 and 45439907790 both completed successfully. The independent error pass reran the public-API scenarios and the unmodified callback-refresh section against the production-only mutation.

Passes (non-blocking): run: core runtime/API/data (winner selection, assignment cache and callback lifetime); dedicated error-handling specialist completed (fallback, logger, refresh and publisher failures); tests/CI/packaging (new Catch2 translation unit, unchanged workflow and both consumers); deployment/operations/observability (changed exposure event emission and payload); cross-cutting simplicity; comment hygiene; diff composition. Not run: shared-component UI (no frontend files); standalone behaviour-bearing data/policy pass (no standalone runtime data, schema, or policy changed; embedded fixtures covered in the test pass).

Comment hygiene (non-blocking): 26 comment / 375 code lines, ratio ~1:14.4, 4 blocks flagged.
threshold T=5; restatements counted: no (10 × C < E)

  • include/absmartly/context.h:136–137 — restates the winner pair and null case.
  • tests/shared_variable_key_test.cpp:47 — restates the adjacent variant fixtures.
  • tests/shared_variable_key_test.cpp:56 — restates the strict-mismatch fixture.
  • tests/shared_variable_key_test.cpp:62 — restates the missing-unit fixture.

Diff composition (non-blocking): every file is required for the change; none flagged. The pinned history audit enumerated the same 20 content writes across 11 commits; exact head and baseline match the content audit from round 1.

Simplifications (non-blocking): 1 candidate.

  • If provider-backed fetching is not part of the winner-removal test's purpose, use direct refresh(data) and remove the one-use FixedDataProvider (roughly 10 fewer code lines; equivalence not established while Q1 is open).

Run a simplification pass locally before pushing: these candidates cost less to address now than as a further review round.

lux worker and others added 3 commits November 26, 2026 22:40
…and exposed-candidate cases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s; note the post-refresh re-exposure

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joalves

joalves commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Q1 (#7 (comment)): the test only needs to pin winner removal, so the direct refresh is enough. In 8e7d29c the winner-removal test calls refresh(data_of({high_exp()})) directly, and the one-use FixedDataProvider and its include are removed. Provider-backed refresh is still covered by the existing Context refresh tests.

@joalves

joalves commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on 63a3780: APPROVE (no P1/P2), 3 P1/P2 fixed across 2 reviewer passes

This round fixes Jervasion's round-1 findings on 3b1915e.

  • Pass 1 on 8fc3e51: REQUEST_CHANGES.
    • P2: the first version of the override guard (id != 0) re-exposed an override on an experiment that is not loaded on every read.
    • P2: the guard was not covered by a test.
    • P2: the value snapshot was not covered by a test.
    • P3: an || exposed mutant of the winner check survived.
    • All of these are fixed in 63a3780 with tests. I confirmed locally that each of the four mutants now fails the suite.
  • Pass 2 on 63a3780: APPROVE. 19 of 20 mutants killed. The 22 Java-recorded scenarios that apply to cpp pass. Public API and ABI are unchanged.

The final reviewer's P3s, plus Jervasion's optional comment-hygiene points and Q1, are handled in the P3-only follow-ups 94a5440 and 8e7d29c (see the next comment). The CHANGELOG entry stays under Fixed, as the owner asked.

Final reviewer report:

.git/sdk-review/63a3780….md

APPROVE at 63a3780: the shared-variable-key resolver implements the owner's Java rule. The lowest-id candidate that is assigned, overridden or rule-assigned wins. Only it is exposed, there is no fall-through, and peek exposes nothing. Head passes 22/22 of the eligible Java-recorded shared-key scenarios (main passes 13/22). The three P2s from the 8fc3e51 review are fixed and pinned. What remains is one P3 test gap (a surviving mutant, reachable only with an experiment id of 0), two P3 doc notes, owner calls on CHANGELOG placement and the version, and one release gate: 63a3780 is not pushed yet, so CI has not run on it.

Compared GitHub release v1.0.0 (tag 9ea8669; cpp-sdk has no package registry) → merge base / origin/main 1c628e4 → head 63a3780. v1.0.0..main has 4 commits (tests, comments and a test-only friend; 0 lines change in src/). Parity was checked against java-sdk core-api Context.getVariableAssignment / isAssignmentCurrent (fetched via gh api) and cross-sdk-tests#52 head 14c967f (scenarios 340-368). The owner superseded the JS rule and references/contracts.md §6 (expose every candidate, fall through), so diverging from them is not a finding. Only this PR's delta is a finding. The remote PR head is 3b1915e; this review covers the local head 63a3780, which is 2 commits ahead (8fc3e51, 63a3780).

Must fix

None. No P1/P2 found.

Tests needed (current implementation correct)

20 full-suite mutations (all 159 cases each): 19 killed, 1 survived.

  • P3 test gap: the experiment->data->id != 0 half of the rebind guard is not pinned (src/context.cpp:621). Mutant M10 drops it (unbound = experiment != nullptr && existing.id == 0) and still passes 159/159. Production is correct. What the mutant does, measured with a probe: a loaded experiment with id == 0 plus an override goes from 1 exposure after 100× treatment() + 100× variable_value() to 200 exposures (head gives 1, main gives 1). That is an unbounded duplicate-exposure loop. The backend never sends id 0, so this is P3. If the owner treats customer-built ContextData (via create_context_with) as able to carry id 0, it becomes P2. Please add a test like "an override on a loaded experiment with id 0 is exposed once": make_exp(0, …), set_override, call treatment() and variable_value() 3 times each, then REQUIRE(pending() == 1). It passes on head and fails under M10.

Compatibility / parity / forward-compat evidence

  • Public surface. include/ diff v1.0.0 → head: context.h only, adding #include <utility> and a private variable_assignment() (plus main's test-only friend). sizeof(Context)=736, sizeof(Assignment)=184 and sizeof(Exposure)=96 are identical on rel, main and head. nm -C of Context:: text symbols, main → head: +1 (the private variable_assignment), 0 removed. models.h is untouched.
  • Released and main suites on head's library. The v1.0.0 tests pass: 140 cases / 1474 assertions. The main tests pass: 141 / 1492. Head's own suite: 159 / 1617. Head's shared_variable_key_test.cpp on main's library: 18 cases, 12 failed / 20 failed assertions. So the new tests do fail on the base.
  • Behaviour sweep, main vs head. 12 UIDs (ASCII, padded, café, CJK, emoji, "0", -1, the string "9007199254740993", 123456789012345678, 1.5, 42, a hex string), 5 experiments (ids 3/5/6/9/30, mixed unit types, one 50% traffic split) and 5 keys, run in three phases: treatment, peek_variable_value, variable_value.
    • The treatment() phase is byte-identical on 12/12 UIDs.
    • The peek phase exposes nothing on both trees.
    • Every peek and variable_value difference falls into a documented class: (a) unassigned candidates e3 (missing unit) and e30 (single-key, missing unit) are no longer exposed; (b) the winner e5 lands on variant 0, which lacks k/m: 10 UIDs because they are outside its 50% traffic split, and "9007199254740993" because the split assigns it variant 0. It therefore returns the default instead of e6's value, and e6 is no longer exposed (11/12 UIDs). UID 42 is assigned e5's treatment arm and gets 5b on both trees.
    • Exposures per UID drop from 5 (4 for UID 42) to 2.
  • Java-recorded conformance. I ran cross-sdk-tests#52 scenarios 340-368 through a local C++ runner that checks results and the full event lists (subset match). Eligible: 22 of 29. 7 skipped because they need holdouts or switchback, which this SDK does not have: 357, 358, 359, 360, 366, 367, 368. Head passes 22/22. Main passes 13/22 (fails 340, 341, 347, 348, 349, 351, 356, 361, 362). These are policy counts from my runner, not the official wrapper lane.
  • Rebind probe (in scope). Override set before low (id 1) is loaded, treatment(low), then refresh() brings low in. Head: variable_value returns low's value ("low" for variant 1, the default for variant 0), and a second exposure [1, low, session_id] is queued once. Later treatment() calls add nothing. Main: it kept the unbound [0, low, ""] and returned high's value. An override on an experiment that never loads: 100× treatment()/peek() gives pending=1 on head (the 8fc3e51 P2 is fixed).
  • Re-entrancy. A logger that calls set_override + peek during the exposure gets the exposed value (M7 is killed). A logger that calls refresh() during the exposure is clean under ASan+UBSan (Debug, 159/159).
  • Java divergence (documented, in scope). Java isAssignmentCurrent does not rebuild a cached override when its experiment loads (when there are no holdouts and no switchback), and neither does JS. The C++ rebind is an owner-requested extension, not parity. It is described in the CHANGELOG.
  • Forward compatibility. The decoder (models.h) is unchanged by this PR. The 22 scenario payloads carry extra keys (applications, customFieldValues: null, assignmentRules) and decode fine. No new decode paths.

Performance

Ordinary path, warmed, pinned to 1 CPU, -O2, 2M iterations × 2 runs. The fixture is 3 experiments: a shared key k (first candidate unassigned, missing unit) and a single-key s. variable_value(s): main 129.1/128.3 ns/op, head 125.4/126.6. peek_variable_value(s): 125.0/126.4 vs 122.4/122.8. variable_value(k): 166.7/166.2 vs 162.8/164.7. peek_variable_value(k): 164.8/164.8 vs 159.1/161.6. So there is no regression; head is about 2-3% faster, within noise. No new cache or memo is added, so no counter test is needed. The rebind costs one extra rebuild per override, once, after the experiment loads (M21, "rebind on every read", is killed by 5 cases). These are synthetic, steady-state, single-thread numbers on aarch64 with GCC 15.2. They are not end-to-end, and allocations were not counted.

P3 / notes

  • P3, CHANGELOG: re-exposure on rebind not spelled out (CHANGELOG.md:34-36). The entry says the exposure "(id, unit type) come[s] from the loaded experiment". It does not say that an override already exposed before the load is exposed a second time (the test pins exposures.size() == 2). Please add "an override exposed before its experiment loaded is exposed once more, with the loaded experiment's id and unit type". This matters to QA/dev users of overrides only.
  • P3, the test name understates what it pins (tests/shared_variable_key_test.cpp:138). "an override on an experiment that is not loaded is exposed once" only calls treatment(). Adding variable_value/peek calls on a key the ghost experiment cannot define changes nothing, so this is optional hardening.
  • Not a finding. Exposure counts drop for unassigned single-key experiments, and there is no fall-through. These are the owner's rule and are documented under Fixed. Do not restore the old behaviour.
  • Not a finding. Java fires holdout exposures for every visited candidate; this SDK has no holdouts, and the PR body flags this to the owner.

Version and release notes

CMake is still 1.0.0, and the entry sits under ## Unreleased / ### Fixed. That is correct for an unreleased fix. The PR adds the missing ## 1.0.0 (2026-11-16) heading over the already-released notes and does not rewrite them (0 removed lines in the CHANGELOG diff from v1.0.0). Owner call: the skill's bar files customer-visible exposure changes under Changed. The owner explicitly asked for Fixed, so this stays. Owner call: the next tag. The change moves exposure counts, so 1.1.0 is safer than 1.0.1; my recommendation is 1.1.0.

Pre-existing on main (not this PR)

  • None found that bears on this diff. v1.0.0..main changes 0 lines in src/.

Verification limits / provenance:

  • CI has not run on 63a3780; the latest green CI is 3b1915e (run 45439925244). Release gate: push and confirm CI is green on 63a3780 before requesting human review.
  • Clang was not run: it is not installed here.
  • Only GCC 15.2 (Release, Debug -Wall -Wextra -Wpedantic -Werror lib target, ASan+UBSan).
  • The official cross-sdk wrapper lane was not run. Scenario counts come from my local runner.
  • JS vectors were not run, because the owner superseded the JS rule.
  • No allocation counting.
  • The package target (cpack) builds TGZ/ZIP; consumer-project CI steps were not rerun because this diff does not touch CMake install rules.

sdk-review evidence: #7

  • Head: 63a378038bffb4a03bac2f132b782b000958f4c8 (local HEAD; remote PR headRefOid is 3b1915e5f30416a146cba17d469a4738394a77c3, 2 commits behind)
  • Mode: independent reviewer (read-only)
  • Previous pass / review: 8fc3e51 (report in .git/sdk-review/8fc3e51….md: REQUEST_CHANGES, 3 P2). Commits since: 1 (63a3780). Commits since remote head 3b1915e: 2 (8fc3e51, 63a3780)
  • Scratch: /tmp/sdkrev.QlrT (worktrees rel/main/head, removed at the end)

1. Trees

Tree Identifier How obtained Verified
Released GitHub release v1.0.0, tag 9ea8669 (no registry for C++) gh release list -R absmartly/cpp-sdk → "v1.0.0 Latest 2026-11-16"; git worktree add rel v1.0.0 tag = commit 9ea8669
Main / merge base 1c628e4 git merge-base origin/main HEAD equals origin/main
Head 63a3780 git rev-parse HEAD
  • git diff --stat 1c628e4 HEAD: 6 files changed (CHANGELOG +35, README +4, context.h +4, context.cpp 65 lines changed, tests/CMakeLists +1, shared_variable_key_test.cpp +481)
  • git diff v1.0.0 1c628e4 --stat: context.h (6) and assignment_rules_test.cpp (69); 0 lines in src
  • Version source: CMake project(absmartly-sdk VERSION 1.0.0), CHANGELOG ## Unreleased above ## 1.0.0 (2026-11-16). These agree for an unreleased change.

2. Backwards compatibility

  • API diff: diff -rq rel/include head/include → only context.h (+#include <utility>, a private variable_assignment, main's private friend). nm -C … | grep " T absmartly::Context::", main vs head: +1 private symbol, 0 removed.
  • ABI layout probe (abi.cpp, sizeof): rel/main/head all give Context=736, Assignment=184, Exposure=96.
  • Released tests vs head lib (rel/tests copied into a head copy, Release build): 140 cases / 1474 assertions, all pass. Main tests vs head lib: 141 / 1492, all pass. Head suite: 159 / 1617, all pass. Main suite on main: 141 / 1492.
  • Failing-first: head's tests on main's library, [shared-variable-key]: 18 cases, 6 passed / 12 failed; 77 assertions, 20 failed.
  • Behaviour sweep (probe/probe.cpp sweep, 12 UIDs × 5 experiments × 5 keys × 3 phases): treatment phase diff = 0 lines. Peek and variable_value differences are all in the documented classes (unassigned candidates not exposed; a winner lacking the key gives the default with no fall-through). Exposures per UID: main 5 (UID 42: 4), head 2.
  • Error/null contract: check_ready(true) is kept on both reads; main's "throw after finalize" and "not ready throws" tests pass on head.
  • Public fields/hooks whose effect changed: none (Assignment::has_variables is no longer read by the resolver, but Assignment is internal state; it is still written).
  • Entry points: every creation path (direct Context, SDK::create_context, create_context_with) goes through the same Context::variable_value/peek_variable_value. Both read APIs are covered by the tests (M13/M14 killed).

3. Parity

  • Java reference: gh api repos/absmartly/java-sdk/contents/core-api/src/main/java/com/absmartly/sdk/Context.java (default branch). getVariableAssignment (l.2077) matches: walk candidates, return the first with assigned || overridden || ruleOverride; holdout/suppressed branches do not apply. isAssignmentCurrent (l.1644) shows that Java does not rebind a cached override when its experiment loads. The C++ rebind is owner scope, not parity.
  • cross-sdk-tests main test_scenarios_complete.json (310 scenarios): only scenario 119 has 2 candidates for one key; it calls treatment() on both first, so neither rule is distinguished.
  • cross-sdk-tests#52 head 14c967f, scenarios 340-368: 22 eligible / 7 skipped of 29 (skipped 357, 358, 359, 360, 366, 367, 368: holdouts/switchback). xsdk/runner.cpp → head pass=22 fail=0 of 22; main pass=13 fail=9 (340, 341, 347, 348, 349, 351, 356, 361, 362).
  • Numeric edge table (§2a): NOT RUN. This diff touches no numeric parsing or assignment math (the hash, split and traffic code is unchanged; the treatment sweep is byte-identical).
  • JS vectors: NOT RUN. The owner superseded the JS shared-key rule.

4. Tests and mutation

  • Full suite on head (GCC 15.2): Release 159 cases / 1617 assertions, all pass. ASan+UBSan Debug: 159 / 1617, all pass. -Wall -Wextra -Wpedantic -Werror C++17 Debug lib target builds cleanly.
  • Mutant driver scripts/mutate.py, applied to a copy (mut/). Full suite each time; mut/src/context.cpp restored and cmp'd to head at the end.
# Mutant (src/context.cpp) Killed by Result
1 expose every unassigned candidate visited (old behaviour) 10 cases (svk_test:120,132,191,255,268…) killed (first run was a script no-op; re-run)
2 fall through when the winner lacks the key 3 cases killed
3 drop rule_override from the winner gate 2 cases killed
4 drop overridden from the winner gate 6 cases killed
5 winner must be eligible 1 case killed
6 winner must match the audience 1 case killed
7 read the value after queue_exposure (snapshot removed) svk_test:177 killed
8 no rebind (!unbound removed) svk_test:448 killed
9 rebind without the experiment != nullptr check 1 case killed
10 rebind without the experiment->data->id != 0 check — SURVIVED (probe: 200 exposures vs 1 for an id-0 override)
11 reverse candidate order 8 cases killed
12 expose on every variable_value read 3 cases killed
13 peek_variable_value exposes 5 cases killed
14 peek falls through 1 case killed
15 rebind keeps the old exposed flag 1 case killed
16 ` exposed` in the winner gate (old P3)
17 winner requires has_variables svk_test:336 killed
18 rebind only when unexposed svk_test:448 killed
19 custom assignment counts as winner svk_test:254 killed
21 rebind on every read (existing.id == 0 dropped) 5 cases killed

Totals: 20 run / 19 killed / 1 survived (M10 → P3 test gap).

  • Standard set (rule env, app_version, ruleKey/attrsSeq stamps, seeds, decoder, wiring, X-Agent): N/A. This diff does not touch that code (the git diff covers only the resolver and the override cache branch).
  • Fix-commit audit:
Commit New state Where it must be set, cleared or read Entry points skipping it Mutant
8fc3e51 value snapshot before queue_exposure variable_value only (peek does not emit) none M7 killed
8fc3e51 → 63a3780 the "unbound override" predicate (existing.id == 0 sentinel) get_or_create_assignment override branch; every reader (treatment, peek, variable_value, peek_variable_value) goes through it; it is cleared by the rebuild, which sets id from the experiment none M8, M9, M18, M21 killed; M10 survived
63a3780 CHANGELOG sentence on binding — — P3 note (second exposure not mentioned)

5. Performance

Path main ns/op (2 runs) head ns/op (2 runs) probe counter test?
variable_value single key 129.1 / 128.3 125.4 / 126.6 2M iterations, taskset 1 CPU, -O2, GCC 15.2, aarch64 no new cache
peek_variable_value single key 125.0 / 126.4 122.4 / 122.8 same n/a
variable_value shared key (first candidate missing unit) 166.7 / 166.2 162.8 / 164.7 same n/a
peek_variable_value shared key 164.8 / 164.8 159.1 / 161.6 same n/a

6. Forward compatibility

  • models.h and the decoder are unchanged (git diff 1c628e4 HEAD -- include/absmartly/models.h is empty). The scenario payloads (22) with applications, customFieldValues: null and assignmentRules decode. A per-level unknown/null/reorder injection was NOT RUN, because the decoder is not in this diff.

7. Build / CI

  • cmake --build b-head --target package → absmartly-cpp-sdk-1.0.0-Linux.tar.gz / .zip generated.
  • Floors: CMake 3.16 and C++17 are unchanged (<utility> is std C++17).
  • Strict build: -Wall -Wextra -Wpedantic -Werror (Debug, C++17) builds the library target with no warnings.
  • CI on this exact head: NOT RUN, because 63a3780 is not pushed. gh run list --branch fix/shared-variable-key-winner → latest is 3b1915e (runs 45439925244 and 45439907790, success). Release gate.
  • Clang: NOT RUN (not installed).
  • Pins: no fixture, submodule or branch pins are changed. The Catch2 URL+SHA256 is unchanged.

8. Docs / CHANGELOG

  • Section: ## Unreleased / ### Fixed (owner's choice). The released notes got their heading ## 1.0.0 (2026-11-16) and were not rewritten (git diff v1.0.0 HEAD -- CHANGELOG.md | grep '^-' gives only the --- header).
  • Migration against the published v1.0.0: no API change. The behaviour changes (exposure counts, no fall-through, unknown-variant override wins with the default, rebind) are all described, except that the rebind's second exposure is not stated (P3).
  • README #### Shared variable keys (README.md:320-322) matches the measured behaviour; it does not mention the rebind (fine, since that is an edge case).
  • Stale strings: grep -rn "1\.0\.0" README.md CMakeLists.txt → only the CMake version and a semver example. Not stale.

Findings

Sev Title Evidence line above Fixed in
P3 id-0 guard in the rebind predicate not pinned (M10 survives; 200 vs 1 exposures for id 0) §4 row 10 —
P3 CHANGELOG does not say a pre-load exposed override is exposed again after the rebind §8 —
P3 ghost-override test covers treatment() only P3 notes —
Gate CI not run on 63a3780 §7 —
Owner Fixed vs Changed placement; next tag 1.0.1 vs 1.1.0 Version section —
Verified fixed (from 8fc3e51) unloaded override re-exposed every read §2 rebind probe ghost pending=1 63a3780
Verified fixed (from 8fc3e51) override guard unpinned M8/M9/M21 killed 63a3780
Verified fixed (from 8fc3e51) value snapshot unpinned M7 killed 63a3780
Verified fixed (from 8fc3e51) ` exposed` survivor

Verification limits

  • CI on 63a3780: NOT RUN (unpushed).
  • Clang: NOT RUN (not installed).
  • JS vectors and numeric edge table: NOT RUN (out of scope for this diff, and the owner superseded the JS rule).
  • Official cross-sdk wrapper lane: NOT RUN; the local runner was used instead.
  • Allocation counts: NOT RUN.
  • Forward-compat injection: NOT RUN (decoder unchanged).

@joalves

joalves commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

P3-only follow-up on top of the gated 63a3780. No production code changed in either commit.

  • 94a5440
    • Adds a test that pins the id-0 half of the rebind guard (the final reviewer's P3). The mutant that drops that half now fails.
    • The CHANGELOG now says that an override already exposed before its experiment loaded is exposed once more after the refresh.
    • Renames the not-loaded override test.
    • Drops the four restating comments Jervasion flagged: three in the test fixtures and one in context.h.
  • 8e7d29c: Jervasion's Q1 and its fixture simplification. The winner-removal test uses the direct refresh(data) overload, and the one-use FixedDataProvider is removed.

Locally: 160/160 tests pass.

@joalves

joalves commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on 8e7d29c: APPROVE (no P1/P2), 0 P1/P2 fixed across 1 reviewer pass

This is a fresh gate on the exact PR head. src/ is byte-identical to the previously gated 63a3780. 14 of 14 mutants are killed, 160/160 tests pass (also under ASan+UBSan), the 22 eligible Java-recorded scenarios all pass, and CI is green on this head.

The reviewer raised two P3s. I am not acting on either, so this head and the pending Jervasion request stay as they are:

  • P3, warmed shared-key reads measured slightly slower (about 2-6%).
    • The previous reviewer measured head slightly faster (2-3%) on a different fixture, so the sign depends on the fixture. This reviewer could not take exact instruction counts.
    • Allocations are 0 per read on both trees.
    • The suggested micro-optimisation (inline the resolver, plus an early return when the winner is already exposed) is speculative until it is measured with stable counters. I'd rather not change production code on that basis.
  • P3, the CHANGELOG could add "(experiments with id 0 are not rebound)".
    • The backend never sends experiment id 0, so this is not customer-visible.
    • The test "an overridden winner with experiment id 0 is exposed once" pins the guard.

If Jervasion raises either point, I'll address it in its batch.

Reviewer report:

.git/sdk-review/8e7d29c….md

APPROVE at 8e7d29c: the shared-variable-key resolver implements the owner's Java rule (lowest-id candidate that is assigned, overridden or rule-assigned wins; only it is exposed; no fall-through; peek exposes nothing), the late-loaded override rebind and the exposed-value snapshot are pinned, 14/14 targeted mutants die, 22/22 eligible Java-recorded scenarios pass (main 13/22), and CI is green on this exact head. All three P3s from the 63a3780 review are fixed. What remains is one P3 performance note (a small, measured slowdown on warmed variable_value/peek_variable_value, 0 allocations either side), one P3 doc note, and owner calls on CHANGELOG placement and the next version.

Compared GitHub release v1.0.0 (tag 9ea8669; cpp-sdk has no package registry) → merge base / origin/main 1c628e4 → head 8e7d29c. v1.0.0..main changes 0 lines in src/ (only a test-only friend plus comments in context.h, and tests). Parity against java-sdk core-api Context.getVariableAssignment (fetched via gh api, main), and cross-sdk-tests#52 head 14c967f (scenarios 340-368). The owner superseded the JS rule and references/contracts.md §6 (expose every candidate, fall through), so diverging from them is not a finding. Only this PR's delta is a finding. Re-reviewed 8e7d29c (2 commits since 63a3780: 94a5440, 8e7d29c); git diff 63a3780 HEAD -- src is empty, so production code is byte-identical to the last reviewed head.

Verified fixed since 63a3780

  • P3 test gap, experiment->data->id != 0 half of the rebind guard: new case "an overridden winner with experiment id 0 is exposed once" (tests/shared_variable_key_test.cpp:131). Mutant M9 (drop id != 0) now fails 1 case (it survived 159/159 last time).
  • P3 CHANGELOG, re-exposure on rebind: CHANGELOG.md:36-37 now says "if it was already exposed before the refresh, it is exposed once more with that data".
  • P3 test name: renamed to "...is exposed once by treatment()".

Must fix

None. No P1/P2 found.

Tests needed (current implementation correct)

14 full-suite mutations (all 160 cases each, Release, GCC 15.2): 14 killed, 0 survived.

  • None needed. Every mutant of the resolver, the exposure, the snapshot and the rebind guard is killed (table in the evidence log).

Compatibility / parity / forward-compat evidence

  • Public surface. include/ diff v1.0.0 → head: context.h only: #include <utility>, a private variable_assignment(), and main's test-only friend. sizeof(Context)=736, sizeof(Assignment)=184, sizeof(Exposure)=96 on rel, main and head. nm -C Context:: T/W symbols main → head: +1 (private variable_assignment), 0 removed.
  • External consumer probe (installed package via find_package(absmartly-sdk); custom ContextEventLogger subclass; variable_value/peek_variable_value/variable_keys): builds and runs identically against rel, main and head installs (1 2 0).
  • Released and main suites on head's library. v1.0.0 tests: 140 cases / 1474 assertions pass. main tests: 141 / 1492 pass. Head suite: 160 / 1624. Head's [shared-variable-key] tests on main's library: 19 cases, 12 failed / 20 failed assertions, so they fail on the base.
  • Behaviour sweep, rel/main vs head. 12 UIDs (ASCII, padded, café, CJK, emoji, "0", -1, "9007199254740993", 123456789012345678, 1.5, 42, hex) × 5 experiments (ids 3/5/6/9/30, mixed unit types, one 50% traffic split) × 4 keys, phases peek → variable_value → treatment. rel and main outputs are byte-identical. Head: treatment() variants identical 12/12; peek exposes 0 on all trees; variable_value exposures per UID drop from 5/4 to 2; every value difference is a documented class (the winner e5 is assigned but outside its traffic split or on variant 0, which lacks k, so head returns the default where main fell through to e6; unassigned e3/e30 no longer exposed).
  • Java-recorded conformance. Local C++ runner over cross-sdk-tests#52 14c967f scenarios 340-368 (result + event-list subset match): 22 eligible / 7 skips of 29 (357, 358, 359, 360, 366, 367, 368 need holdouts/switchback, which this SDK does not have). Head 22/22; main 13/22 (fails 340, 341, 347, 348, 349, 351, 356, 361, 362). These are counts from my runner, not the official wrapper lane (the cpp-wrapper at 14c967f needs absmartly/switchback.h from cpp-sdk#6 and does not build against this branch).
  • Java parity of the resolver. getVariableAssignment (java-sdk Context.java:2077) returns the first assigned || overridden || ruleOverride candidate and the caller returns the default if the winner's variables lack the key; head matches line for line apart from holdout/switchback branches this SDK does not have.
  • Rebind probe (in scope). Override set before one (id 1) loads, treatment("one"), then refresh brings it in: head returns "one" and has 2 exposures, last {id:1, unit:session_id}; 50 more treatment+variable_value reads add none. main returns the default and keeps {id:0, unit:""}. An override on an experiment that never loads stays at 1 exposure (pinned by test).
  • Sanitizers / warnings. Debug + ASan + UBSan: 160/160 clean. Debug -Wall -Wextra -Wpedantic -Werror: builds, 160/160.
  • Forward compatibility. The decoder (models.h) is unchanged by this PR; the 22 scenario payloads carry extra keys (applications, customFieldValues: null) and decode. No new decode path.

Performance

Warmed ordinary path, no rules/audience, 3 experiments (shared key k whose first candidate has no unit; single-key s), 2M iterations, pinned to 1 CPU, -O2, GCC 15.2, aarch64; median of 7 interleaved runs (ns/op):

read main head
variable_value(s) 66.2 68.0
peek_variable_value(s) 65.0 66.6
variable_value(k) 106.4 112.6
peek_variable_value(k) 105.8 108.8

Allocations per warmed read: 0.00 on both trees for all four. Control reads this PR does not touch (peek()/treatment()): main 36.4-36.7 / 36.9-37.4, head 37.5-37.7 / 37.7-37.9 in the default build, and equal (36.4-36.7 vs 36.5-36.7) when both libraries are built with -falign-functions=64, while variable_value(k) stays slower in that build (105.0-113.4 vs 108.4-111.5, noisier). So roughly 2-6 ns/op (≈2-6%) appears attributable to the change, probably the out-of-line resolver call plus the value copy taken before the exposed check; forcing the resolver inline recovered most of the peek_variable_value(k) gap but not all of variable_value(k). The 63a3780 review measured head 2-3% faster with a different fixture, so the sign is not robust across fixtures. Hardware instruction counters are blocked in this sandbox (perf_event_open: EPERM), so I could not get a deterministic count. Synthetic, steady-state, single-thread; not end-to-end. No new cache or memo, so no counter test is needed.

P3 / notes

  • P3 performance, small measured slowdown on warmed shared-key reads (src/context.cpp:302-348). Numbers above: +1.6-1.8 ns single-key, +3.0-6.2 ns shared-key, 0 allocations either side, sign differs from the previous review's fixture. I file it as P3 rather than P2 because it is a few ns, allocation-free, not reproducible in sign across fixtures, and production behaviour is correct; if the owner applies the "any measured ordinary-path regression is P2" bar literally, it moves up. Optional: make variable_assignment inline in the .cpp (it has two callers) and, in variable_value, return the found value directly when assignment->exposed is already true, then re-measure.
  • P3 doc, id-0 late load is not rebound (src/context.cpp:621). Measured: an override cached before an experiment with id 0 loads keeps the unbound assignment after refresh (value = default, 1 exposure with id 0). That is the deliberate cost of the id != 0 guard (the id-0 loaded case would otherwise re-expose forever, pinned at tests/shared_variable_key_test.cpp:131), and the backend never sends id 0. Optional: add "(experiments with id 0 are not rebound)" to the CHANGELOG sentence, or leave as is.
  • Not a finding. Exposure counts drop for unassigned single-key experiments, and there is no fall-through. That is the owner's rule, documented under Fixed. Do not restore the old behaviour.
  • Not a finding. The C++ rebind of a late-loaded override is an owner-requested extension (Java and JS do not rebuild a cached override when its experiment loads). It is documented in the CHANGELOG.
  • Housekeeping, not this PR. The repo has six stale worktrees registered from earlier review runs (/tmp/sdkrev.0iMc/*, /tmp/sdkrev.jBgT/*). Mine were removed; those were left as found.

Version and release notes

CMake is 1.0.0; the entry is under ## Unreleased / ### Fixed; the PR adds the missing ## 1.0.0 (2026-11-16) heading over the released notes without rewriting them (0 removed lines in the CHANGELOG diff from v1.0.0). Owner call (decided): the skill's bar files customer-visible exposure changes under Changed; the owner explicitly asked for Fixed, so it stays. Owner call (open): the next tag. Exposure counts move, so 1.1.0 is safer than 1.0.1; recommendation 1.1.0.

Pre-existing on main (not this PR)

  • None found that bears on this diff. v1.0.0..main changes 0 lines in src/.

Verification limits / provenance: All builds and runs on aarch64, GCC 15.2, CMake 4.2; Clang not installed (not run). Official cross-sdk-tests wrapper lane not run (cpp-wrapper needs cpp-sdk#6's switchback.h); scenario counts come from my own runner. Hardware perf counters unavailable (EPERM), so performance is wall-clock only. CI on this exact head: run 45910526705 (pull_request) and 45910520855 (push), "Build & test" success. No JS/numeric-edge vectors run: the diff touches no hashing, split, numeric or header code. Published-registry step not applicable (no registry; GitHub tag v1.0.0 used as release).


sdk-review evidence: #7

  • Head: 8e7d29c058a7128d8cd96317cb203e1bb24702b4 (gh pr view 7 --json headRefOid → same; git ls-remote refs/pull/7/head → same)
  • Mode: independent reviewer (read-only)
  • Previous pass / review: 63a378038bffb4a03bac2f132b782b000958f4c8 (commits since: 2 — 94a5440 test id-0 overridden winner, drop comments, CHANGELOG re-exposure note; 8e7d29c test uses direct refresh(data) overload)
  • Scratch: /tmp/tmp.zjC09Cyf8l (worktrees removed at the end; git status --short → 0 lines)
  • Finished (UTC): 2026-11-27T10:24Z

1. Trees

Tree Identifier How obtained Verified
Released GitHub tag v1.0.0 (9ea8669); no package registry git tag → v1.0.0; git worktree add rel v1.0.0 tag commit
Main / merge base 1c628e4 git merge-base origin/main HEAD == origin/main
Head 8e7d29c git rev-parse HEAD == PR head
Version source / CHANGELOG: CMakeLists.txt:2 VERSION 1.0.0; CHANGELOG ## Unreleased above ## 1.0.0 (2026-11-16); `git diff v1.0.0 HEAD -- CHANGELOG.md grep -c '^-[^-]'` → 0 (released notes not rewritten).
git diff --quiet 63a3780 HEAD -- src → SRC_IDENTICAL. git diff --stat 63a3780 HEAD → CHANGELOG (+2/-1), context.h (-2 comment lines), shared_variable_key_test.cpp (+15/-22).

2. Backwards compatibility

  • API diff: git diff v1.0.0 HEAD -- include → context.h only: +<utility>, +private variable_assignment, +test-only friend (main), comment changes. nm -C --defined-only lib | grep Context:: main vs head → +1 private symbol, 0 removed. sizeof Context/Assignment/Exposure: rel 736/184/96, main 736/184/96, head 736/184/96.
  • Consumer probe (/tmp/tmp.zjC09Cyf8l/consumer, find_package(absmartly-sdk) against cmake --install of each tree; logger subclass + both reads + variable_keys): rel ✓ 1 2 0, main ✓ 1 2 0, head ✓ 1 2 0. (ABI run-old-on-new not applicable: static library.)
  • Released tests vs head lib (src+include of head swapped into rel/main trees): release 140 cases / 1474 assertions pass; main 141 / 1492 pass; head own 160 / 1624 pass. Extra failures: none.
  • Head's new tests on main lib ([shared-variable-key]): 19 cases, 7 passed, 12 failed; 84 assertions, 20 failed.
  • No-rule behaviour sweep (probe/sweep.cpp, 12 UIDs × 5 experiments × 4 keys): cmp s-rel.txt s-main.txt → identical. Head differs only in documented classes (see review); treatment() variants identical 12/12; peek pending 0 on all trees; vv pending main 5/4 → head 2.
  • Error/null/logging contract: check_ready(true) kept on both reads; default returned for unknown key on all trees (nope=D); no new events or event types.
  • Public fields/hooks whose effect changed: none (no public field touched).
  • Entry points: constructor-with-data (all tests), refresh(ContextData) and refresh() via provider (tests at 63a3780; now direct overload) × variable_value / peek_variable_value / treatment / peek. Fetch/future path shares the same Context internals (not separately probed).

3. Parity

  • Java reference: gh api repos/absmartly/java-sdk/contents/core-api/src/main/java/com/absmartly/sdk/Context.java (main), getVariableAssignment at line 2077, getVariableValue 727, peekVariableValue 779: same winner predicate and default-on-missing-key; holdout/switchback branches N/A.
  • JS: superseded by owner decision (not compared).
  • Numeric edge table: NOT RUN — diff touches no hashing/split/numeric/header code.
  • cross-sdk-tests: git clone --branch consolidate/sdk-round-2026-11 → 14c967f; runner runner/r.cpp (result + event subset match) over 340-368: 22 eligible / 7 skips of 29 (357 358 359 360 366 367 368: holdouts/switchback). Head pass=22 fail=0; main pass=13 fail=9 (340 341 347 348 349 351 356 361 362). Official cpp-wrapper build: fails absmartly/switchback.h: No such file on both main and head (wrapper pinned to cpp-sdk#6).

4. Tests and mutation

  • Full suite on head: Release 160 cases / 1624 assertions pass; Debug ASan+UBSan 160/160; Debug -Wall -Wextra -Wpedantic -Werror builds, 160/160.
  • Harness: tools/mut.py (one mutant at a time on a copy of head, incremental rebuild, full suite).
# Mutant (src/context.cpp) Failing cases Result
M1 winner ignores overridden (:311) 7 (context_test, shared_variable_key_test) killed
M2 winner ignores rule_override 2 (assignment_rules_test, shared) killed
M3 winner ignores assigned 18 killed
M4 fall-through when winner lacks key 3 (shared) killed
M5 expose every visited candidate (old behaviour) 14 (+ segfault rc -11) killed
M6 peek_variable_value exposes the winner 5 killed
M7 value re-resolved after exposure (no snapshot) 2 (shared) killed
M8 no rebind (drop !unbound, :622) 1 (shared) killed
M9 rebind ignores data->id != 0 (:621) 1 (shared, new id-0 test) killed
M10 rebind on every read 6 killed
M11 re-expose on every variable_value 4 killed
M12 candidates in descending id 8 killed
M13 variable_value never exposes 16 killed
M14 winner requires has_variables 1 (shared) killed
Totals: 14 run / 14 killed / 0 survived.

Standard-set items not applicable (no rule-scope, app_version, header, decoder, numeric or cache code in this diff).

  • Fix-commit audit (commits since 63a3780):
Commit New state Where else it must be set/cleared/read Entry points skipping it Mutant
94a5440 none in production (tests, CHANGELOG, header comments removed) — — M9 now killed by the new id-0 test
8e7d29c none in production (test uses refresh(ContextData) instead of a provider) the provider path refresh() delegates to refresh(ContextData) (src/context.cpp:563-575), so coverage is equivalent — —

5. Performance

Path main head probe / runtime counter test?
variable_value(s) warmed 66.2 ns 68.0 ns 2M iter, median of 7 interleaved runs, taskset -c 1, -O2, GCC 15.2, aarch64 n/a (no cache added)
peek_variable_value(s) 65.0 66.6 same n/a
variable_value(k) shared 106.4 112.6 same n/a
peek_variable_value(k) shared 105.8 108.8 same n/a
allocs/op (all four) 0.00 0.00 counting operator new, 1000 reads —
control peek()/treatment() default build 36.3-36.7 / 36.9-37.4 37.5-37.7 / 37.7-37.9 3 runs —
control, both built -falign-functions=64 36.4-36.5 / 36.9-37.0 36.5-36.7 / 36.9-37.3 3 runs —
variable_value(k), aligned build 105.0-113.4 108.4-111.5 3 runs —
Variants tried: resolver forced inline (inl): k reads 107.0-111.2 / 103.3-104.5; inline + early return when exposed (v2): 108.3-112.0 / 103.1-104.9. Instruction counts: NOT RUN (perf_event_open → EPERM).

6. Forward compatibility

  • Decoder untouched by this PR (git diff origin/main...HEAD -- include/absmartly/models.h empty). Scenario payloads with applications, customFieldValues: null decode on head (22/22 contexts ready). Full key injection/removal matrix: NOT RUN (no decode change).

7. Build / CI

  • Package: cmake --install build-head --prefix inst → rc 0; consumer find_package build ✓ (step 2).
  • Floors: cmake_minimum_required(VERSION 3.16) and C++17 unchanged (CMakeLists.txt not in diff).
  • Strict warnings: Debug -Wall -Wextra -Wpedantic -Werror → builds, 160/160.
  • Clang: NOT RUN (not installed). PR body states Clang 22 passed at the production-fix commit; production unchanged since.
  • CI on this exact head: gh run list --commit 8e7d29c… → run 45910526705 (pull_request) "Build & test" success; run 45910520855 (push) "Build & test" success.
  • Pins: none added by this PR.

8. Docs / CHANGELOG

  • Section: ## Unreleased / ### Fixed (owner-requested); new ## 1.0.0 (2026-11-16) heading over already-released notes, 0 released lines removed.
  • Migration vs published API: no public API change; the behaviour change (exposure counts, no fall-through, rebind + re-exposure) is described with who is affected.
  • README: new "Shared variable keys" paragraph matches the measured behaviour (traffic-excluded unit gets control and is exposed: sweep UIDs where e5 wins on variant 0 → default + 1 e5 exposure).
  • Stale strings: git grep -n "1\.0\.1\|1\.1\.0" -- CHANGELOG.md README.md CMakeLists.txt → 0 hits.

Findings

Sev Title Evidence line above Fixed in
P3 Small measured slowdown on warmed shared-key reads (0 allocs) §5 table —
P3 id-0 late-loaded override not rebound (by design; doc only) review "P3 / notes", probe probe/p.cpp id0-late-load: value=default pending=1 —
Owner Fixed vs Changed placement (decided: Fixed) §8 —
Owner Next tag 1.0.1 vs 1.1.0 (recommend 1.1.0) §1 —

Verification limits

  • Clang build: NOT RUN (toolchain absent).
  • Official cross-sdk-tests wrapper lane: NOT RUN (wrapper requires cpp-sdk#6 headers); local runner used.
  • Hardware instruction counters: NOT RUN (EPERM).
  • Numeric edge table / JS vectors / forward-compat injection matrix: NOT RUN — no code in those areas changed.
  • Future-based (create_context fetch) entry point not separately probed; it shares the same Context read path.

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested

The shared-variable resolver and the earlier callback/refresh fixes now behave correctly in the covered cases, but one remediation regression remains: a valid experiment ID of 0 is still being used as the “not yet bound” sentinel for cached overrides. That can return the caller default and emit incomplete exposure metadata when an override is set before an ID-0 experiment is loaded.

Next step: Distinguish an override-only cached assignment from a bound assignment without using the experiment ID as the sentinel, then add coverage for the pre-load override → refresh path with experiment ID 0.

Must fix

  1. Do not use experiment ID 0 as the unbound marker — an override cached before its experiment arrives must bind to a subsequently loaded experiment even when its valid ID is 0; otherwise variable_value() returns the default and the exposure carries stale/missing experiment data. src/context.cpp:621

Suggestions

  • None — the previously requested provider-fixture simplification was applied.

What I checked

  • ✅ Release build and all 160 CTest cases passed, including all shared-variable-key tests.
  • ✅ Exact-head GitHub Actions CI runs completed successfully for the reviewed SHA.
  • ✅ The callback/logger and refresh fixes from the previous review now have distinguishing tests and no longer reproduce the prior findings.
  • ✅ A focused harness reproduces the remaining ID-0 pre-load override regression.
Review details

Head: 8e7d29c058a7128d8cd96317cb203e1bb24702b4
Base and merge-base: 1c628e4dee98c24ec16a697bb382363d89bad723
Round: 3 (follow-up).

Convergence summary — review round 3

  • Unresolved original blockers: 0
  • Remediation regressions: 1
  • Independent PR-change findings: 0
  • Acceptance criteria still open: an override cached before loading must bind to the refreshed experiment and use its variant variables, unit, iteration, and exposure metadata regardless of whether the experiment ID is zero.
  • Human adjudication requested: no — the regression is verified and has a focused fix direction.

The prior three findings are resolved at this head: pre-load overrides bind for nonzero experiment IDs; variable_value() captures the selected value before the logger callback; and the refresh-on-exposure test now returns the original value while the next lookup observes the refreshed empty snapshot. The remaining issue is in the remediation added for the first finding (63a3780), retained at this head.

Passes (non-blocking): run: core runtime/API/data; dedicated error-handling specialist (completed); tests/CI/packaging; deployment/operations/observability; cross-cutting simplicity; comment hygiene; diff composition. Not run: shared-component UI (no frontend source changed); behaviour-bearing data/policy (no runtime data, schema, or policy files changed).

Comment hygiene (non-blocking): 25 comment / 423 code lines, ratio ~1:16.9, 3 blocks flagged.
threshold T=5; restatements counted: no (10 × C < E)

  • tests/shared_variable_key_test.cpp:47 — adjacent fixture description restates the variant definitions.
  • tests/shared_variable_key_test.cpp:56 — adjacent fixture comment restates the strict-mismatch setup.
  • tests/shared_variable_key_test.cpp:62 — adjacent fixture comment restates the missing-unit setup.

Diff composition (non-blocking): every file is required for the change; none flagged. The introduced-content audit completed successfully for the cumulative merge-base..head history; no credential, scratch artifact, cache, or unnecessary file was found.

Simplifications (non-blocking): none.

Validation commands: git diff --check 1c628e4dee98c24ec16a697bb382363d89bad723..8e7d29c058a7128d8cd96317cb203e1bb24702b4; cmake -S . -B /workspace/repo/cpp-sdk-review-build -DCMAKE_BUILD_TYPE=Release -DABSMARTLY_BUILD_TESTS=ON; cmake --build /workspace/repo/cpp-sdk-review-build --parallel 4; ctest --test-dir /workspace/repo/cpp-sdk-review-build --output-on-failure; and the pinned introduced-blobs audit. Exact-head Actions runs 45910526705 and 45910520855 both completed with conclusion success.

Comment thread src/context.cpp Resolved
lux worker and others added 3 commits November 27, 2026 11:39
…el; snapshot treatment()'s variant

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t data; pin the rebind checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d return; rewrap CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joalves

joalves commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on dd5b15c: APPROVE (no P1/P2), 1 P1/P2 fixed across 2 reviewer passes

This round fixes Jervasion's round-3 finding on 8e7d29c: experiment id 0 was being used as the marker for "not yet bound".

  • d033110. The id-based marker is gone. When refresh() brings in an experiment that had an override cached while it was unloaded, that cached override is now dropped. The next read rebuilds it from the loaded experiment's data, for any id including 0.
    • The same commit snapshots treatment()'s variant before the exposure logger runs, matching the snapshot already in variable_value().
    • Pass 1 on d033110: REQUEST_CHANGES.
      • P2 test gap: nothing caught an override being erased on every refresh while its experiment stayed unloaded.
      • P3: an override was exposed again when its experiment left and came back unchanged.
  • dd5b15c. Fixes both. The cached override is now dropped only when the returning experiment's data differs from what it was bound to: id, unit type, iteration, or whether its variant exists. Tests cover each of those four comparisons, the unloaded-across-refreshes case, and the leave-and-return-unchanged case. Mutating any of them fails the suite.
  • Pass 2 on dd5b15c: APPROVE. 18 of 19 mutants killed. The survivor is the off-by-one P3, covered in the next comment. 161/161 tests pass, including the ASan+UBSan -Werror build. Public headers are unchanged.

The final reviewer's two P3s are handled in the test/docs-only follow-up 6e54bb9 (next comment). The CHANGELOG entry stays under Fixed, as the owner asked.

Final reviewer report:

.git/sdk-review/dd5b15c….md

APPROVE at dd5b15c: both findings from the d033110 review are fixed and measured. The M11-class mutant (re-exposing a still-unloaded override on refresh) is now killed, and a bound override whose experiment leaves and comes back unchanged is exposed once again, as on main. Two P3s remain. One new comparison in the rebind check (has_variables, with a variant equal to the variant count) has a surviving off-by-one mutant. One CHANGELOG line runs to 99 characters. Before the human review, CI must also be green on this head, which has not been pushed.

Compared tag v1.0.0 (GitHub release; cpp-sdk has no package registry) → merge base / origin/main 1c628e4 → previous reviewed head d033110 → head dd5b15c. Parity is against java-sdk Context.getVariableAssignment, the rule the owner chose; the winner code is unchanged since 8e7d29c, where it was compared with Java and cross-sdk-tests. Only this PR's delta counts as a finding. Re-reviewed dd5b15c (1 commit since d033110).

Verified fixed since d033110

  • P2 test gap (M11: unloaded override erased on every refresh). The new test "an override on an experiment that stays unloaded across refreshes is exposed once" (tests/shared_variable_key_test.cpp:475) kills the equivalent mutant M15 on head: 1 failing case. Probe B (override on an unloaded x, two refreshes, three treatments) gives 1 exposure on main, d033110 and head.
  • P3 (bound override re-exposed on leave and return). refresh() (src/context.cpp:608-622) now erases a recorded override only when id, unit_type, iteration or has_variables differ from the returning experiment. Probe A (override x=1 on id 5; refresh without x; refresh with x unchanged) gives 1 exposure on main, 2 on d033110 and 1 on head. It is pinned by the new test at :486. The changed-field test at :499 (GENERATE over id/iteration/unitType) kills the drop-id, drop-unit_type and drop-iteration mutants (M11-M13).
  • Pre-load binding is unchanged by this commit. Probe C (override before load, then id 7 / iteration 3 loads) and probe D (id 0) both give vv="x" and a second exposure with the loaded id and unit=session_id on head. On main the result is vv="h", with the value taken from a later experiment. The change is intended and documented.

Must fix

None.

Tests needed (current implementation correct)

19 full-suite mutations: 18 killed, 1 survived:

  • M19, src/context.cpp:617: static_cast<size_t>(existing.variant) < …variables.size() changed to <=. The full suite still passes (161 cases, 1652 assertions). Production is correct. The mutant is observable only for a bound override whose variant index equals the variant count and whose experiment leaves and returns unchanged: the mutant computes variant_has_variables=true while the cached value is false, so it erases and re-exposes. This P3 test kills it. I ran it on a scratch copy; it passes on head (3 assertions) and fails on M19 (1 failed case):
    Context ctx(make_config(), data_of({low_exp(), high_exp()}));
    ctx.set_override(LOW, 2);              // low_exp() has variants 0 and 1
    REQUIRE(ctx.treatment(LOW) == 2);
    ctx.refresh(data_of({high_exp()}));
    ctx.refresh(data_of({low_exp(), high_exp()}));
    REQUIRE(ctx.treatment(LOW) == 2);
    REQUIRE(ctx.pending() == 1);

Compatibility / parity / forward-compat evidence

  • Public API: include/ is byte-identical to d033110 (git diff --quiet d033110 HEAD -- include). Against v1.0.0 the header adds only #include <utility>, a private variable_assignment and the test-only friend struct ContextTestAccess (from main); main dropped two comment lines. There are no new virtuals and no layout change to public structs.
  • Released tests against the head library (head src/ and include/ copied into the v1.0.0 and 1c628e4 trees): v1.0.0 suite 140 cases / 1474 assertions, all pass; main suite 141 / 1492, all pass. Head's own suite 161 / 1652, all pass. No extra failures.
  • Behaviour probe (probe/p.cpp, linked against each tree's libabsmartly-sdk.a), main / d033110 / head:
    • A: leave and return unchanged: 1 / 2 / 1 exposures.
    • B: unloaded override across 2 refreshes: 1 / 1 / 1.
    • C: pre-load override binds to id 7: main vv="h"; d033110 and head vv="x", second exposure id=7 unit=session_id (intended).
    • D: same as C with id 0: main vv="h"; d033110 and head vv="x", second exposure id=0 unit=session_id (intended).
    • E: id-0, unitType "", iteration-0 experiment arrives for an out-of-range override: 1 / 2 / 1. Head keeps the placeholder because it already equals the loaded data.
    • F: bound out-of-range override (variant 2 of 2) returns with a third variant added: main vv="h", 1 x-exposure; d033110 and head vv="x", 2 x-exposures (rebinds because has_variables changed). This is consistent with "returns changed binds to the new data". Main fell through to h, which the owner's rule now forbids.
  • A config-only change to an overridden variant (same id/unit/iteration) keeps the cached variables ("old") on main and head alike, both staying loaded and leaving and returning. Pre-existing; see below.
  • Java parity: variable_assignment, variable_value and peek_variable_value are byte-identical to 8e7d29c (git show dd5b15c -- src touches only refresh()). Not re-run.

Performance

Single run each, taskset -c 1, -O2, GCC 15.2, aarch64, 2-experiment fixture. Synthetic, not end-to-end:

  • warmed treatment() x 2M: main 31.89 ns, d033110 34.74 ns, head 32.03 ns;
  • warmed variable_value() x 2M: main 87.81 ns, d033110 88.05 ns, head 86.21 ns;
  • refresh(same data) x 200k: main 2009.1 ns, d033110 2032.0 ns, head 2027.7 ns (+0.9% vs main, within one-run noise; not on the read path).
    The read paths show no measurable change. The new refresh work is one scan of assignments_ plus a per-override comparison for overrides that were unloaded.

P3 / notes

  1. P3 test gap: M19 survives (src/context.cpp:616-617). See above. Please add the test shown.
  2. P3 CHANGELOG wrap: CHANGELOG.md:39 is 99 characters. Every other line in the entry wraps at about 76 characters. Please rewrap lines 38-41.
  3. Note: once the experiment loads, the has_variables term also decides whether a placeholder override (id 0, empty unit, iteration 0) is kept or rebound. This matches the test at :521, which needs the term for an id-0 / no-unit experiment. It is correct, and M14 (drop the term) is killed.

Version and release notes

  • CMakeLists.txt:2 VERSION 1.0.0. The CHANGELOG has ## Unreleased / ### Fixed (owner's request) above ## 1.0.0 (2026-11-16). git diff v1.0.0 HEAD -- CHANGELOG.md removes 0 released lines. A grep for 1.0.1/1.1.0 in CHANGELOG/README/CMakeLists returns 0 hits.
  • The new sentence "An override already bound to an experiment that leaves and returns unchanged is not exposed again" matches probe A and the test at :486.
  • Owner call (unchanged): next tag 1.0.1 or 1.1.0. I recommend 1.1.0 because exposure counts change for shared-key and audience-mismatch users.

Pre-existing on main (not this PR)

  • An overridden assignment keeps its cached variant variables when the experiment's variant config changes and the id, unit and iteration stay the same: vv="old" after loading "new" on main and head. This is outside this PR's scope; track separately if it matters.
  • Non-overridden units re-expose when their experiment leaves and returns (measured on main in the d033110 review, probe A2).

Verification limits / provenance: dd5b15c is not pushed. The PR head on GitHub is 8e7d29c (gh pr view 7 --json headRefOid), and the latest CI runs, 45910526705 and 45910520855 (success), are on 8e7d29c. There is no CI run for dd5b15c; CI must go green after the push and before the re-request. Not run: Clang (not installed); cross-sdk-tests, the JS/numeric vector table and the forward-compat injection matrix (no winner, decode, hash or header code changed since 8e7d29c); the external consumer probe (headers identical to d033110, where it compiled); allocation counters. All counts come from local GCC 15.2 Release builds plus one Debug ASan+UBSan -Werror build, in worktrees under /tmp/tmp.ebxmacSRAA. These were removed afterwards, and the branch working tree is clean. Worktrees under /tmp/tmp.YegtkQkebm and /tmp/sdkrev.* belong to other runs and were left untouched.


sdk-review evidence: cpp-sdk#7

  • Head: dd5b15c7db0dd416e949099f31fcc8895d7457ea (local; gh pr view 7 --json headRefOid → 8e7d29c058a7128d8cd96317cb203e1bb24702b4, so not pushed yet)
  • Mode: independent reviewer (read-only)
  • Previous review: d033110ff0607f607ee56db1987f914f32ebefaa (commits since: 1, dd5b15c "keep an override bound to unchanged returning experiment data; pin the rebind checks")
  • Scratch: /tmp/tmp.ebxmacSRAA (worktrees head, main, rel, prev; copies x-rel, x-main, mut; asan build). Removed at the end.
  • Finished: 2026-11-27

1. Trees

Tree Identifier How obtained Verified
Released tag v1.0.0 (9ea8669); no registry git tag → v1.0.0; git worktree add --detach rel v1.0.0 tag commit
Main / merge base 1c628e4 git merge-base origin/main HEAD → 1c628e4… == origin/main
Previous head d033110 previous report .git/sdk-review/d033110….md
Head dd5b15c git rev-parse HEAD local, unpushed
  • Version: CMakeLists.txt:2 project(absmartly-sdk VERSION 1.0.0 …). CHANGELOG ## Unreleased / ### Fixed above ## 1.0.0 (2026-11-16).
  • git diff v1.0.0 HEAD -- CHANGELOG.md | grep -c '^-[^-]' → 0.
  • git show dd5b15c --stat → CHANGELOG.md +2/-1, src/context.cpp +16/-6, tests/shared_variable_key_test.cpp +57.

2. Backwards compatibility

  • git diff --quiet d033110 HEAD -- include → identical. git diff v1.0.0 HEAD -- include: +<utility>, +private variable_assignment, +test-only friend (main), −2 comment lines (main).
  • Consumer probe: NOT RE-RUN; headers identical to d033110, where rel, main and head compiled.
  • Released tests against the head lib (cp -r head/src head/include into copies of the v1.0.0 and 1c628e4 trees, cmake --build): x-rel "All tests passed (1474 assertions in 140 test cases)"; x-main "All tests passed (1492 assertions in 141 test cases)".
  • Own suites: main 141/1492 pass; d033110 161/1634 pass; head 161/1652 pass.
  • Behaviour probe probe/p.cpp (g++ -O2 … libabsmartly-sdk.a), output lines main / prev / head:
    • A: 1 [id=5] / 2 [id=5, id=5] / 1 [id=5]
    • B: 1 / 1 / 1
    • C: main vv="h" n=2 [id=0 x, id=9 h]; prev and head vv="x" n=2 [id=0 x u="", id=7 x u=session_id]
    • D: main vv="h"; prev and head vv="x" [id=0 u="", id=0 u=session_id]
    • E: 1 / 2 / 1
    • F: main vv="h" n=2 [x v=2, h]; prev and head vv="x" n=2 [x v=2, x v=2]
  • Probe probe/q.cpp (override config change, same id/unit/iteration): main and head both vv="old" pending=1, staying loaded and leaving and returning. Pre-existing.
  • Public fields/hooks whose effect changed: none.
  • Entry points: constructor with data; refresh(ContextData); refresh() delegates to it (src/context.cpp:572-585). Reads: treatment, peek, variable_value, peek_variable_value (unchanged since 8e7d29c).

3. Parity

  • Java getVariableAssignment: winner code unchanged since 8e7d29c. NOT RE-RUN (at 8e7d29c: cross-sdk-tests 340-368, 22 eligible / 7 skips of 29, 22/22 pass).
  • Numeric edge table: NOT RUN (no numeric, hash or header code in the diff).

4. Tests and mutation

  • Full suite on head: Release 161 cases / 1652 assertions pass in 0.017 s (wall). Debug with -fsanitize=address,undefined -Wall -Wextra -Wpedantic -Werror: builds with no warnings, 161/1652 pass.
  • Harness tools/mut.py on copy mut: one mutant at a time, full suite each time, source restored afterwards.
# Mutant (src/context.cpp) Failing cases Result
M1 winner ignores overridden 7 killed
M2 winner ignores rule_override 2 killed
M3 winner ignores assigned 18 killed
M4 fall through when the winner lacks the key 3 killed
M5 expose every visited candidate 14 (rc -11) killed
M6 peek_variable_value exposes 5 killed
M7 value re-read after exposure 1 killed
M8 treatment returns the live variant (re-lookup) 1 killed
M9 rebind erase removed 1 killed
M10 erase every recorded override unconditionally (d033110 behaviour) 1 killed
M11 drop the id comparison 1 killed
M12 drop the unit_type comparison 1 killed
M13 drop the iteration comparison 1 killed
M14 drop the has_variables comparison 1 killed
M15 erase an override even while still unloaded 1 killed
M16 record all overrides, not only unloaded ones 3 killed
M17 variable_value never exposes 16 killed
M18 winner requires has_variables 1 killed
M19 < → <= in variant_has_variables (:617) 0 SURVIVED
Totals: 19 run / 18 killed / 1 survived (M19 → P3 test gap).
  • Kill test for M19 (appended to a scratch copy of the test file as [review]): head "All tests passed (3 assertions in 1 test case)", full suite 162/1655 pass. tools/mut.py M19 → 1 failed of 162 (killed). M14 is also killed by it.
  • Fix-commit audit:
Commit New state Where it must be set/cleared/read Entry points skipping it Mutant
dd5b15c refresh-local unloaded_overrides + 4-field equality check before erase must compare every field queue_exposure publishes from the cached override (id, unit, variant, overridden; assigned etc. are false for overrides) plus the variables source; variant is already equal (same override), so id/unit_type/iteration cover the published fields; has_variables covers placeholder vs loaded constructor, become_ready, become_failed call build_index() without it (fine: assignments_ is empty, or the context failed); set_override does not touch assignments_ (the get_or_create_assignment variant check covers it) M10-M15 killed; M19 survived
dd5b15c variables content not compared a config-only change keeps stale variables; same as main (probe q) — pre-existing

5. Performance

Path main d033110 head probe
warmed treatment() 31.89 ns 34.74 32.03 2M iterations, 1 run, taskset -c 1, -O2 GCC 15.2 aarch64
warmed variable_value() 87.81 ns 88.05 86.21 2M iterations
refresh(same data), 2 experiments 2009.1 ns 2032.0 2027.7 200k iterations
No cache added by this commit, so no counter test is needed.

6. Forward compatibility

  • NOT RUN: decoder untouched (git diff origin/main...HEAD -- include/absmartly/models.h empty).

7. Build / CI

  • Release builds of head, main and d033110: rc 0. ASan+UBSan -Werror Debug build: rc 0, no warnings.
  • Floors unchanged (CMakeLists.txt not in the PR diff; CMake 3.16 / C++17).
  • CI on dd5b15c: NOT AVAILABLE. gh run list --branch fix/shared-variable-key-winner → latest 45910526705 and 45910520855 (success) on 8e7d29c; dd5b15c is unpushed.
  • Clang: NOT RUN (which clang++ → none).
  • Pins: none.

8. Docs / CHANGELOG

  • Entry under ### Fixed (owner decision). The new sentence matches probe A.
  • awk 'length($0)>80' CHANGELOG.md → line 39 (99 characters) → P3.
  • Stale strings: git grep -n "1\.0\.1\|1\.1\.0" -- CHANGELOG.md README.md CMakeLists.txt → 0.

Findings

Sev Title Evidence Fixed in
P3 Test gap: <= off-by-one in variant_has_variables survives (M19) §4 M19 + kill test —
P3 CHANGELOG line 39 is 99 characters, unwrapped §8 awk —
Owner Next tag 1.0.1 vs 1.1.0 §1 —
Gate No CI on dd5b15c (unpushed) §7 —

Verification limits

  • dd5b15c has no CI run (unpushed). Not run: Clang; cross-sdk-tests; JS/numeric vectors; forward-compat matrix; consumer probe (headers unchanged); allocation counters. Performance figures come from one run each.

@joalves

joalves commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

P3-only follow-up on top of the gated dd5b15c: 6e54bb9 changes only tests and the CHANGELOG, no production code.

  • Test. Adds a test that pins the bounds check in the rebind comparison, using an override to the variant one past the last as its experiment leaves and returns. I confirmed that the < → <= mutant the final reviewer found now fails the suite.
  • CHANGELOG. Rewraps the over-long line in the entry.

Locally: 161/161 tests pass.

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved

The previous ID-0 override regression is fixed. Pre-load overrides now bind based on whether the experiment data was loaded, and the refresh comparisons preserve or rebuild bound assignments correctly across ID, iteration, unit-type, and variant-data changes. The callback-safe return snapshots also remain correct.

Next step: None — ready to merge.

What I checked

  • ✅ Full Release build and all 161 CTest cases passed.
  • ✅ The new ID-0 pre-load binding and refresh/override transition cases pass, including the one-past-last variant case.
  • ✅ Exact-head GitHub Actions CI runs 46005005513 and 46004993914 completed successfully.
  • ✅ Focused runtime and error-handling passes found no additional verified defects.
  • ✅ The previous round’s blocker is resolved and no new blocking issue was found.
Review details

Head: 6e54bb98eff67220da6764a2ef1a8f6b82944895
Base and merge-base: 1c628e4dee98c24ec16a697bb382363d89bad723
Round: 4 (follow-up).

Convergence summary — review round 4

  • Unresolved original blockers: 0
  • Remediation regressions: 0
  • Independent PR-change findings: 0
  • Acceptance criteria still open: none
  • Human adjudication requested: no

The round-3 remediation regression is resolved: refresh() records overrides cached while their experiment was unloaded, drops the placeholder when the experiment arrives, and lets the next read rebuild from the loaded data without using ID 0 as a sentinel. Bound overrides are retained when the returning experiment data is unchanged and rebuilt when ID, iteration, unit type, or variant-variable availability changes. treatment() and variable_value() snapshot their return values before callbacks can mutate the context.

Passes (non-blocking): run: core runtime/API/data; dedicated error-handling specialist (completed); tests/CI/packaging; deployment/operations/observability; cross-cutting simplicity; comment hygiene; diff composition. Not run: shared-component UI (no frontend source changed); behaviour-bearing data/policy (no runtime data, schema, or policy files changed).

Comment hygiene (non-blocking): 29 comment / 525 code lines, ratio ~1:18.1, 3 blocks flagged.
threshold T=6; restatements counted: no (10 × C < E)

  • tests/shared_variable_key_test.cpp:47 — adjacent fixture description restates the variant definitions.
  • tests/shared_variable_key_test.cpp:56 — adjacent fixture comment restates the strict-mismatch setup.
  • tests/shared_variable_key_test.cpp:62 — adjacent fixture comment restates the missing-unit setup.

Diff composition (non-blocking): every file is required for the change; none flagged. The introduced-content audit completed successfully for the cumulative merge-base..head history; no credential, scratch artifact, cache, or unnecessary file was found.

Simplifications (non-blocking): none.

Validation commands: git diff --check 1c628e4dee98c24ec16a697bb382363d89bad723..6e54bb98eff67220da6764a2ef1a8f6b82944895; cmake -S . -B /workspace/repo/cpp-sdk-review-build-r4 -DCMAKE_BUILD_TYPE=Release -DABSMARTLY_BUILD_TESTS=ON; cmake --build /workspace/repo/cpp-sdk-review-build-r4 --parallel 4; ctest --test-dir /workspace/repo/cpp-sdk-review-build-r4 --output-on-failure; and the pinned introduced-blobs audit. Exact-head Actions runs 46005005513 and 46004993914 both completed with conclusion success.

@joalves

joalves commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Independent sdk-review on 6e54bb9: APPROVE (no P1/P2/P3), 0 P1/P2 fixed across 1 reviewer pass

This is the final gate on the exact head Jervasion approved. It is a fresh reviewer with no findings.

  • The library code is identical to the gated dd5b15c.
  • 21 of 22 mutants are killed. The one survivor cannot change behaviour.
  • 161/161 tests pass, including the ASan+UBSan -Werror build.
  • The v1.0.0 and main test suites pass against this head's library.
  • CI is green on this SHA.

The only open item is the owner's version call: the reviewer recommends 1.1.0. No commit was pushed after this review.

Final reviewer report:

.git/sdk-review/6e54bb9….md

APPROVE at 6e54bb9: both P3s from the dd5b15c review are fixed and measured. The M19 off-by-one mutant is now killed by the new test at tests/shared_variable_key_test.cpp:498, and the CHANGELOG is rewrapped, with no line over 80 characters. The library sources are byte-identical to dd5b15c. The full suite, the released and main suites against the head library, and an ASan+UBSan -Werror build all pass. CI is green on this exact head. No P1, P2 or P3 remains. One owner call is left: the next version number.

Compared tag v1.0.0 (GitHub tag; cpp-sdk has no package registry) → merge base / origin/main 1c628e4 → previous reviewed head dd5b15c → head 6e54bb9. Parity is against java-sdk Context.getVariableAssignment, the rule the owner chose, which supersedes the contracts §6 JS fall-through rule. Only this PR's delta is a finding. Re-reviewed 6e54bb9 (1 commit since dd5b15c: a test plus a CHANGELOG rewrap).

Verified fixed since dd5b15c

  • P3 test gap M19 (< → <= in variant_has_variables, src/context.cpp:617). The new section "an override to a variant one past the last that leaves and returns is not exposed again" (tests/shared_variable_key_test.cpp:498) kills it. With the mutant, the full suite gives 160 passed and 1 failed of 161.
  • P3 CHANGELOG wrap. awk 'length($0)>80' CHANGELOG.md returns 0 lines.

Must fix

None.

Tests needed (current implementation correct)

22 full-suite mutations: 21 killed, 1 survived. The survivor is equivalent, so it is not a finding:

  • M20, src/context.cpp:616: existing.variant >= 0 changed to >= -1. This is equivalent: static_cast<size_t>(-1) already fails the < variables.size() bound on the next line, so no input can tell the two apart. The guard is defensive.
    All the others are killed, including the winner predicate (assigned, overridden and rule terms each), the fall-through, expose-every-candidate, peek exposing, the post-logger value re-read, the treatment() re-lookup, each rebind comparison (id, unit_type, iteration, has_variables, the < bound), erase-while-unloaded, record-all-overrides, a reversed id order, and falsy values treated as missing.

Compatibility / parity / forward-compat evidence

  • Public API: git diff --quiet dd5b15c HEAD -- include src → identical. Against v1.0.0, include/ adds only #include <utility>, the private variable_assignment and the test-only friend (from main). It adds no virtuals and changes no public struct layout.
  • Released tests against the head library (head src/ and include/ copied into the v1.0.0 and 1c628e4 trees): v1.0.0 suite 140 cases / 1474 assertions, all pass; main suite 141 / 1492, all pass. Head's own suite: 161 / 1655, all pass.
  • Behaviour probe (probe/p.cpp linked against each tree's lib). Every main → head difference is a documented, intended change:
    • S1, strict-mismatched lower-id candidate: main exposes x and h; head exposes only h. Both return "h".
    • S4, override set before load: main returns "h" and exposes x#0 and h; head returns "x" and exposes x#0 and then x#1 with unit session_id. This is the documented "exposed once more with that data".
    • S6 (override -1) and S7 (override to an unknown variant 5): main returns "h" from a later experiment; head returns the default and exposes x. This matches the CHANGELOG line "An override to a variant the experiment does not have".
    • S2, a winner without the key: both return "h". This is correct on both, because x's assigned arm here is control, which lacks the key, and h is assigned.
    • S3, peek: both expose nothing.
    • S5, leave and return: both 1 exposure.
    • UID sweep (a, 0, -1, é, emoji, 9007199254740993, " pad "): same variants on main and head. Only the 2^53+1 UID, which is control in both experiments, differs: main exposes x and h and returns "d"; head exposes only x and returns "d". This matches the owner's no-fall-through rule.
  • Java parity: the winner code is unchanged since 8e7d29c, where it was compared with Java and cross-sdk-tests. Not re-run.

Performance

Warmed reads, 2M iterations, 2 runs each, taskset -c 1, -O2, GCC 15.2, aarch64, 2-experiment fixture. Synthetic, not end-to-end:

  • treatment(): main 32.16 / 32.20 ns, head 34.61 / 33.16 ns.
  • variable_value(): main 73.22 / 73.19 ns, head 70.73 / 69.96 ns.
  • peek_variable_value(): main 72.56 / 72.70 ns, head 69.79 / 68.63 ns.
    The treatment() delta of +1 to 2.4 ns comes from one extra int copy and is within run-to-run noise (the previous review measured 31.89 vs 32.03 ns). No cache is added, so no counter test is needed.

P3 / notes

None.

Version and release notes

  • CMakeLists.txt:2 VERSION 1.0.0, unchanged by this PR. The CHANGELOG has ## Unreleased / ### Fixed (owner's request) above ## 1.0.0 (2026-11-16). 0 released lines removed. A grep for 1.0.1/1.1.0 in CHANGELOG/README/CMakeLists returns 0 hits.
  • Owner call (unchanged): next tag 1.0.1 or 1.1.0. I recommend 1.1.0 because exposure counts change for shared-key and audience-mismatched users.

Pre-existing on main (not this PR)

  • An overridden assignment keeps its cached variant variables after a config-only change to its variant when id, unit and iteration stay the same (measured in the dd5b15c review).
  • Non-overridden units are re-exposed when their experiment leaves and returns.

Verification limits / provenance: Not run: Clang (none installed); cross-sdk-tests, the JS/numeric vector table, the forward-compat injection matrix and the external consumer probe. Nothing in the winner, decoder, hash, header or include/ code changed since 8e7d29c/dd5b15c, where they were run or compiled. Allocation counters were not run. All counts come from local GCC 15.2 Release builds plus one Debug ASan+UBSan -Werror build in /tmp/sdkrev6e.qI8I, removed afterwards. The branch working tree is unchanged.


sdk-review evidence: cpp-sdk#7

  • Head: 6e54bb98eff67220da6764a2ef1a8f6b82944895 (gh pr view 7 --json headRefOid → same)
  • Mode: independent reviewer (read-only)
  • Previous review: dd5b15c7db0dd416e949099f31fcc8895d7457ea (commits since: 1, 6e54bb9 "pin the one-past-last override variant across leave and return; rewrap CHANGELOG")
  • Scratch: /tmp/sdkrev6e.qI8I (worktrees head, main, rel, prev; copies x-rel, x-main, mut; asan; probe). Removed at the end.
  • Finished: 2026-11-27

1. Trees

Tree Identifier How obtained Verified
Released tag v1.0.0; no registry git tag → v1.0.0; git worktree add --detach rel v1.0.0 tag commit
Main / merge base 1c628e4 git merge-base origin/main HEAD == origin/main
Previous head dd5b15c .git/sdk-review/dd5b15c….md
Head 6e54bb9 git rev-parse HEAD == PR head
  • Version: CMakeLists.txt:2 VERSION 1.0.0. CHANGELOG ## Unreleased / ### Fixed. git diff v1.0.0 HEAD -- CHANGELOG.md | grep -c '^-[^-]' → 0.
  • git show 6e54bb9: CHANGELOG.md, 3 lines rewrapped; tests/shared_variable_key_test.cpp +10 lines.

2. Backwards compatibility

  • git diff --quiet dd5b15c HEAD -- include src → identical. The v1.0.0 → head include diff: context.h +6/-2 (utility include, private method, friend from main).
  • Consumer probe: NOT RE-RUN (headers identical to d033110/dd5b15c, where it compiled).
  • Released tests against the head lib: x-rel rc=0 "All tests passed (1474 assertions in 140 test cases)"; x-main rc=0 "All tests passed (1492 assertions in 141 test cases)".
  • Own suites: rel 140/1474, main 141/1492, prev 161/1652, head 161/1655, all rc=0.
  • Behaviour probe probe/p.cpp S1-S7 plus a 7-UID sweep, main vs head: diffs listed in the review, all documented.
  • Public fields/hooks whose effect changed: none (no header change since dd5b15c).
  • Entry points: constructor with data, refresh(ContextData), refresh() → treatment, peek, variable_value, peek_variable_value. The probe goes through the constructor and refresh(ContextData).

3. Parity

  • Java getVariableAssignment: winner code unchanged since 8e7d29c. NOT RE-RUN (at 8e7d29c: cross-sdk-tests 340-368, 22 eligible / 7 skips of 29, 22/22 pass).
  • Numeric edge table: NOT RUN (no numeric, hash or header code in the diff).

4. Tests and mutation

  • Full suite on head: Release 161 cases / 1655 assertions, rc 0. Debug -fsanitize=address,undefined -fno-sanitize-recover=all -Wall -Wextra -Wpedantic -Werror: builds with no warnings, 161/1655 pass.
  • Harness tools/mut.py on copy mut: one mutant at a time, full suite each time, source restored afterwards.
# Mutant (src/context.cpp) Failing cases of 161 Result
M1 winner ignores overridden 7 killed
M2 winner ignores rule_override 2 killed
M3 winner ignores assigned 18 killed
M4 fall through when the winner lacks the key 3 killed
M5 expose every visited candidate 14 (rc -11) killed
M6 peek_variable_value exposes 5 killed
M7 value re-read after exposure 1 killed
M8 treatment re-looks up the variant after exposure 1 killed
M9 rebind erase removed 1 killed
M10 always erase recorded overrides 1 killed
M11 drop the id comparison 1 killed
M12 drop the unit_type comparison 1 killed
M13 drop the iteration comparison 1 killed
M14 drop the has_variables comparison 1 killed
M15 erase while still unloaded 1 killed
M16 record all overrides 3 killed
M17 variable_value never exposes 16 killed
M18 winner requires has_variables 1 killed
M19 < → <= (:617) 1 killed (new test :498)
M20 variant >= 0 → >= -1 (:616) 0 survived, EQUIVALENT (size_t(-1) fails the bound)
M21 candidates by id descending 8 killed
M22 falsy value treated as missing 1 killed
Totals: 22 run / 21 killed / 1 survived (equivalent; not a finding).
  • Fix-commit audit:
Commit New state Where it must be set/cleared/read Entry points skipping it Mutant
6e54bb9 none (test plus docs only) — — M19 now killed

5. Performance

Path main head probe
warmed treatment() 32.16 / 32.20 ns 34.61 / 33.16 ns 2M, 2 runs, taskset -c 1, -O2 GCC 15.2 aarch64
warmed variable_value() 73.22 / 73.19 ns 70.73 / 69.96 ns same
warmed peek_variable_value() 72.56 / 72.70 ns 69.79 / 68.63 ns same
No cache added, so no counter test is needed.

6. Forward compatibility

  • NOT RUN: decoder untouched (git diff --quiet origin/main HEAD -- include/absmartly/models.h → identical).

7. Build / CI

  • Release builds of rel, main, prev and head: rc 0. ASan/UBSan -Werror: rc 0.
  • Floors unchanged (CMakeLists.txt identical to origin/main; CMake 3.16 / C++17).
  • CI on this exact head: push run 46004993914 (headSha 6e54bb9, job "Build & test" success); pull_request run 46005005513 (headSha 6e54bb9, success).
  • Clang: NOT RUN (not installed).
  • Pins: none.

8. Docs / CHANGELOG

  • Entry under ### Fixed (owner decision). Its claims match probes S1, S4, S6 and S7.
  • awk 'length($0)>80' CHANGELOG.md → 0 lines.
  • Stale strings: git grep -n "1\.0\.1\|1\.1\.0" -- CHANGELOG.md README.md CMakeLists.txt → 0.

Findings

Sev Title Evidence Fixed in
(prev P3) M19 test gap §4 M19 killed 6e54bb9
(prev P3) CHANGELOG wrap §8 awk 6e54bb9
Owner Next tag 1.0.1 vs 1.1.0 §1 —

Verification limits

  • Not run: Clang; cross-sdk-tests; JS/numeric vectors; forward-compat matrix; consumer probe (headers unchanged); allocation counters. Performance figures come from 2 runs each.

@joalves
joalves merged commit 324c623 into main Nov 27, 2026
3 checks passed
@joalves joalves mentioned this pull request Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants